Repository: incubator-juneau Updated Branches: refs/heads/master 87f505b38 -> dc5d9afb1
Improvements to serializer/parser settings. Project: http://git-wip-us.apache.org/repos/asf/incubator-juneau/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-juneau/commit/dc5d9afb Tree: http://git-wip-us.apache.org/repos/asf/incubator-juneau/tree/dc5d9afb Diff: http://git-wip-us.apache.org/repos/asf/incubator-juneau/diff/dc5d9afb Branch: refs/heads/master Commit: dc5d9afb1f4f0e65c683b0e0b568192249089ab9 Parents: 87f505b Author: JamesBognar <[email protected]> Authored: Sun Oct 8 13:24:56 2017 -0400 Committer: JamesBognar <[email protected]> Committed: Sun Oct 8 13:24:56 2017 -0400 ---------------------------------------------------------------------- .../apache/juneau/jena/RdfParserSession.java | 17 ++++++++++-- .../juneau/jena/RdfSerializerSession.java | 22 +++++++++++++-- .../java/org/apache/juneau/BeanSession.java | 24 ++++++++-------- .../main/java/org/apache/juneau/ObjectMap.java | 14 ++++++++++ .../main/java/org/apache/juneau/UriContext.java | 3 +- .../juneau/html/HtmlDocSerializerSession.java | 21 ++++++++++++++ .../juneau/html/HtmlSerializerSession.java | 18 ++++++++++-- .../juneau/json/JsonSerializerSession.java | 11 +++++++- .../msgpack/MsgPackSerializerSession.java | 10 ++++++- .../org/apache/juneau/parser/ParserSession.java | 15 +++++++++- .../juneau/serializer/SerializerSession.java | 29 ++++++++++++++++++-- .../org/apache/juneau/uon/UonParserSession.java | 10 ++++++- .../apache/juneau/uon/UonSerializerContext.java | 18 ++++++------ .../apache/juneau/uon/UonSerializerSession.java | 19 +++++++++---- .../urlencoding/UrlEncodingParserSession.java | 12 ++++++-- .../urlencoding/UrlEncodingSerializer.java | 2 +- .../UrlEncodingSerializerSession.java | 12 ++++++-- .../org/apache/juneau/xml/XmlParserSession.java | 14 +++++++++- .../apache/juneau/xml/XmlSerializerSession.java | 16 ++++++++++- .../yaml/proto/YamlSerializerSession.java | 7 +++++ .../apache/juneau/rest/RestServletDefault.java | 5 ++++ 21 files changed, 253 insertions(+), 46 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/dc5d9afb/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParserSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParserSession.java b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParserSession.java index 04e779f..f9d9440 100644 --- a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParserSession.java +++ b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfParserSession.java @@ -59,7 +59,7 @@ public class RdfParserSession extends ReaderParserSession { ObjectMap jenaSettings = new ObjectMap(); jenaSettings.putAll(ctx.jenaSettings); ObjectMap p = getProperties(); - if (p.isEmpty()) { + if (! p.containsKeyPrefixes(RdfParserContext.PREFIX, "Rdf.")) { this.rdfLanguage = ctx.rdfLanguage; this.juneauNs = ctx.juneauNs; this.juneauBpNs = ctx.juneauBpNs; @@ -71,7 +71,7 @@ public class RdfParserSession extends ReaderParserSession { this.juneauNs = (p.containsKey(RDF_juneauNs) ? NamespaceFactory.parseNamespace(p.get(RDF_juneauNs)) : ctx.juneauNs); this.juneauBpNs = (p.containsKey(RDF_juneauBpNs) ? NamespaceFactory.parseNamespace(p.get(RDF_juneauBpNs)) : ctx.juneauBpNs); this.trimWhitespace = p.getBoolean(RdfParserContext.RDF_trimWhitespace, ctx.trimWhitespace); - this.collectionFormat = RdfCollectionFormat.valueOf(p.getString(RDF_collectionFormat, "DEFAULT")); + this.collectionFormat = p.getWithDefault(RDF_collectionFormat, ctx.collectionFormat, RdfCollectionFormat.class); this.looseCollections = p.getBoolean(RDF_looseCollections, ctx.looseCollections); } this.model = ModelFactory.createDefaultModel(); @@ -90,6 +90,19 @@ public class RdfParserSession extends ReaderParserSession { } } + @Override /* Session */ + public ObjectMap asMap() { + return super.asMap() + .append("RdfParser", new ObjectMap() + .append("collectionFormat", collectionFormat) + .append("looseCollections", looseCollections) + .append("juneauNs", juneauNs) + .append("juneauBpNs", juneauBpNs) + .append("rdfLanguage", rdfLanguage) + .append("trimWhitespace", trimWhitespace) + ); + } + @Override /* ReaderParserSession */ protected <T> T doParse(ParserPipe pipe, ClassMeta<T> type) throws Exception { http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/dc5d9afb/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java index 9c0e701..918d405 100644 --- a/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java +++ b/juneau-core/juneau-marshall-rdf/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java @@ -71,7 +71,7 @@ public final class RdfSerializerSession extends WriterSerializerSession { jenaSettings.put("rdfXml.attributeQuoteChar", Character.toString(getQuoteChar())); jenaSettings.putAll(ctx.jenaSettings); ObjectMap p = getProperties(); - if (p.isEmpty()) { + if (! p.containsKeyPrefixes(RdfSerializerContext.PREFIX, "Rdf.")) { this.rdfLanguage = ctx.rdfLanguage; this.juneauNs = ctx.juneauNs; this.juneauBpNs = ctx.juneauBpNs; @@ -94,7 +94,7 @@ public final class RdfSerializerSession extends WriterSerializerSession { if (key.startsWith("Rdf.jena.")) jenaSettings.put(key.substring(9), e.getValue()); } - this.collectionFormat = RdfCollectionFormat.valueOf(p.getString(RDF_collectionFormat, "DEFAULT")); + this.collectionFormat = p.getWithDefault(RDF_collectionFormat, ctx.collectionFormat, RdfCollectionFormat.class); this.looseCollections = p.getBoolean(RDF_looseCollections, ctx.looseCollections); this.useXmlNamespaces = p.getBoolean(RDF_useXmlNamespaces, ctx.useXmlNamespaces); this.autoDetectNamespaces = p.getBoolean(RDF_autoDetectNamespaces, ctx.autoDetectNamespaces); @@ -120,6 +120,24 @@ public final class RdfSerializerSession extends WriterSerializerSession { writer.setProperty(e.getKey().substring(propPrefix.length()), e.getValue()); } + @Override /* Session */ + public ObjectMap asMap() { + return super.asMap() + .append("RdfSerializerSession", new ObjectMap() + .append("addBeanTypeProperties", addBeanTypeProperties) + .append("addLiteralTypes", addLiteralTypes) + .append("addRootProperty", addRootProperty) + .append("autoDetectNamespaces", autoDetectNamespaces) + .append("collectionFormat", collectionFormat) + .append("juneauNs", juneauNs) + .append("juneauBpNs", juneauBpNs) + .append("looseCollections", looseCollections) + .append("namespaces", namespaces) + .append("rdfLanguage", rdfLanguage) + .append("useXmlNamespaces", useXmlNamespaces) + ); + } + /* * Adds the specified namespace as a model prefix. */ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/dc5d9afb/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java index 64d165c..b26c8bf 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/BeanSession.java @@ -58,7 +58,7 @@ public class BeanSession extends Session { this.ctx = ctx; Locale _locale = null; ObjectMap p = getProperties(); - if (p == null || p.isEmpty()) { + if (p == null || ! p.containsKeyPrefix(BeanContext.PREFIX)) { _locale = (args.locale != null ? args.locale : ctx.locale); this.timeZone = (args.timeZone != null ? args.timeZone : ctx.timeZone); this.debug = ctx.debug; @@ -72,6 +72,18 @@ public class BeanSession extends Session { this.locale = _locale == null ? Locale.getDefault() : _locale; } + @Override /* Session */ + public ObjectMap asMap() { + return super.asMap() + .appendAll(ctx.asMap()) + .append("BeanSession", new ObjectMap() + .append("debug", debug) + .append("locale", locale) + .append("mediaType", mediaType) + .append("timeZone", timeZone) + ); + } + /** * Returns the locale defined on this session. * @@ -1079,16 +1091,6 @@ public class BeanSession extends Session { } @Override /* Session */ - public final ObjectMap asMap() { - return super.asMap() - .appendAll(ctx.asMap()) - .append("BeanSession", new ObjectMap() - .append("locale", locale) - .append("timeZone", timeZone) - ); - } - - @Override /* Session */ public boolean close() throws BeanRuntimeException { if (super.close()) { if (debug && hasWarnings()) http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/dc5d9afb/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ObjectMap.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ObjectMap.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ObjectMap.java index 4c376d2..4fc6927 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ObjectMap.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/ObjectMap.java @@ -1203,6 +1203,20 @@ public class ObjectMap extends LinkedHashMap<String,Object> { } /** + * Same as {@link #containsKeyPrefix(String)} except returns <jk>true</jk> if this map contains at least one + * of the specified prefixes. + * + * @param prefixes The string prefixes. + * @return <jk>true</jk> if this map contains a key with at least one of the specified string prefix. + */ + public boolean containsKeyPrefixes(String...prefixes) { + for (String p : prefixes) + if (containsKeyPrefix(p)) + return true; + return false; + } + + /** * Returns <jk>true</jk> if this map contains the specified key, ignoring the inner map if it exists. * * @param key The key to look up. http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/dc5d9afb/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/UriContext.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/UriContext.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/UriContext.java index 2890984..8a19332 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/UriContext.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/UriContext.java @@ -42,7 +42,8 @@ public class UriContext { */ public static final UriContext DEFAULT = new UriContext(); - final String authority, contextRoot, servletPath, pathInfo, parentPath; + @SuppressWarnings("javadoc") + public final String authority, contextRoot, servletPath, pathInfo, parentPath; // Lazy-initialized fields. private String aContextRoot, rContextRoot, aServletPath, rResource, aPathInfo, rPath; http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/dc5d9afb/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java index 43a2d69..e7ffa6b 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java @@ -46,6 +46,8 @@ public class HtmlDocSerializerSession extends HtmlStrippedDocSerializerSession { protected HtmlDocSerializerSession(HtmlDocSerializerContext ctx, SerializerSessionArgs args) { super(ctx, args); ObjectMap p = getProperties(); + + // TODO - Change this to p.containsKeyPrefix(PREFIX) if (p.isEmpty()) { header = ctx.header; nav = ctx.nav; @@ -75,6 +77,25 @@ public class HtmlDocSerializerSession extends HtmlStrippedDocSerializerSession { } } + @Override /* Session */ + public ObjectMap asMap() { + return super.asMap() + .append("HtmlDocSerializerSession", new ObjectMap() + .append("aside", aside) + .append("head", head) + .append("header", header) + .append("footer", footer) + .append("nav", nav) + .append("navlinks", navlinks) + .append("noResultsMessage", noResultsMessage) + .append("nowrap", nowrap) + .append("script", script) + .append("style", style) + .append("stylesheet", stylesheet) + .append("template", template) + ); + } + /** * Returns the {@link HtmlDocSerializerContext#HTMLDOC_style} setting value in this context. * http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/dc5d9afb/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerSession.java index 3f1f1fd..056f6f1 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerSession.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerSession.java @@ -14,7 +14,6 @@ package org.apache.juneau.html; import static org.apache.juneau.html.HtmlSerializerSession.ContentResult.*; import static org.apache.juneau.html.HtmlSerializerContext.*; -import static org.apache.juneau.msgpack.MsgPackSerializerContext.*; import static org.apache.juneau.xml.XmlUtils.*; import java.io.*; @@ -68,7 +67,7 @@ public class HtmlSerializerSession extends XmlSerializerSession { super(ctx, args); String labelParameter; ObjectMap p = getProperties(); - if (p.isEmpty()) { + if (! p.containsKeyPrefix(HtmlSerializerContext.PREFIX)) { anchorText = Enum.valueOf(AnchorText.class, ctx.uriAnchorText); detectLinksInStrings = ctx.detectLinksInStrings; lookForLabelParameters = ctx.lookForLabelParameters; @@ -81,11 +80,24 @@ public class HtmlSerializerSession extends XmlSerializerSession { lookForLabelParameters = p.getBoolean(HTML_lookForLabelParameters, ctx.lookForLabelParameters); labelParameter = p.getString(HTML_labelParameter, ctx.labelParameter); addKeyValueTableHeaders = p.getBoolean(HTML_addKeyValueTableHeaders, ctx.addKeyValueTableHeaders); - addBeanTypeProperties = p.getBoolean(MSGPACK_addBeanTypeProperties, ctx.addBeanTypeProperties); + addBeanTypeProperties = p.getBoolean(HTML_addBeanTypeProperties, ctx.addBeanTypeProperties); } labelPattern = Pattern.compile("[\\?\\&]" + Pattern.quote(labelParameter) + "=([^\\&]*)"); } + @Override /* Session */ + public ObjectMap asMap() { + return super.asMap() + .append("HtmlSerializerSession", new ObjectMap() + .append("addBeanTypeProperties", addBeanTypeProperties) + .append("addKeyValueTableHeaders", addKeyValueTableHeaders) + .append("anchorText", anchorText) + .append("detectLinksInStrings", detectLinksInStrings) + .append("labelPattern", labelPattern) + .append("lookForLabelParameters", lookForLabelParameters) + ); + } + /** * Converts the specified output target object to an {@link HtmlWriter}. * http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/dc5d9afb/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializerSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializerSession.java index e1eeec0..8718641 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializerSession.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializerSession.java @@ -50,7 +50,7 @@ public class JsonSerializerSession extends WriterSerializerSession { protected JsonSerializerSession(JsonSerializerContext ctx, SerializerSessionArgs args) { super(ctx, args); ObjectMap p = getProperties(); - if (p.isEmpty()) { + if (! p.containsKeyPrefix(JsonSerializerContext.PREFIX)) { simpleMode = ctx.simpleMode; escapeSolidus = ctx.escapeSolidus; addBeanTypeProperties = ctx.addBeanTypeProperties; @@ -61,6 +61,15 @@ public class JsonSerializerSession extends WriterSerializerSession { } } + @Override /* Session */ + public ObjectMap asMap() { + return super.asMap() + .append("JsonSerializerSession", new ObjectMap() + .append("addBeanTypeProperties", addBeanTypeProperties) + .append("escapeSolidus", escapeSolidus) + .append("simpleMode", simpleMode) + ); + } @Override /* SerializerSesssion */ protected void doSerialize(SerializerPipe out, Object o) throws Exception { http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/dc5d9afb/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerSession.java index 6a2f4f4..bc0e2ca 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerSession.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerSession.java @@ -48,13 +48,21 @@ public final class MsgPackSerializerSession extends OutputStreamSerializerSessio protected MsgPackSerializerSession(MsgPackSerializerContext ctx, SerializerSessionArgs args) { super(ctx, args); ObjectMap p = getProperties(); - if (p.isEmpty()) { + if (! p.containsKeyPrefix(MsgPackSerializerContext.PREFIX)) { addBeanTypeProperties = ctx.addBeanTypeProperties; } else { addBeanTypeProperties = p.getBoolean(MSGPACK_addBeanTypeProperties, ctx.addBeanTypeProperties); } } + @Override /* Session */ + public ObjectMap asMap() { + return super.asMap() + .append("MsgPackSerializerSession", new ObjectMap() + .append("addBeanTypeProperties", addBeanTypeProperties) + ); + } + /** * Returns the {@link MsgPackSerializerContext#MSGPACK_addBeanTypeProperties} setting value for this session. * http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/dc5d9afb/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSession.java index 7992a2e..0e884eb 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSession.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserSession.java @@ -59,7 +59,7 @@ public abstract class ParserSession extends BeanSession { ctx = ParserContext.DEFAULT; Class<?> listenerClass; ObjectMap p = getProperties(); - if (p.isEmpty()) { + if (! p.containsKeyPrefix(ParserContext.PREFIX)) { trimStrings = ctx.trimStrings; strict = ctx.strict; inputStreamCharset = ctx.inputStreamCharset; @@ -77,6 +77,19 @@ public abstract class ParserSession extends BeanSession { this.listener = newInstance(ParserListener.class, listenerClass); } + @Override /* Session */ + public ObjectMap asMap() { + return super.asMap() + .append("ParserSession", new ObjectMap() + .append("fileCharset", fileCharset) + .append("inputStreamCharset", inputStreamCharset) + .append("javaMethod", javaMethod) + .append("listener", listener) + .append("outer", outer) + .append("strict", strict) + .append("trimStrings", trimStrings) + ); + } //-------------------------------------------------------------------------------- // Abstract methods http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/dc5d9afb/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSession.java index 450fc2f..ae4a206 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSession.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/serializer/SerializerSession.java @@ -100,7 +100,7 @@ public abstract class SerializerSession extends BeanSession { UriRelativity uriRelativity; Class<?> listenerClass; ObjectMap p = getProperties(); - if (p.isEmpty()) { + if (! p.containsKeyPrefix(SerializerContext.PREFIX)) { maxDepth = ctx.maxDepth; initialDepth = ctx.initialDepth; detectRecursions = ctx.detectRecursions; @@ -135,8 +135,8 @@ public abstract class SerializerSession extends BeanSession { sortCollections = p.getBoolean(SERIALIZER_sortCollections, ctx.sortMaps); sortMaps = p.getBoolean(SERIALIZER_sortMaps, ctx.sortMaps); abridged = p.getBoolean(SERIALIZER_abridged, ctx.abridged); - uriResolution = p.getWithDefault(SERIALIZER_uriResolution, UriResolution.ROOT_RELATIVE, UriResolution.class); - uriRelativity = p.getWithDefault(SERIALIZER_uriRelativity, UriRelativity.RESOURCE, UriRelativity.class); + uriResolution = p.getWithDefault(SERIALIZER_uriResolution, ctx.uriResolution, UriResolution.class); + uriRelativity = p.getWithDefault(SERIALIZER_uriRelativity, ctx.uriRelativity, UriRelativity.class); listenerClass = p.getWithDefault(SERIALIZER_listener, ctx.listener, Class.class); } @@ -152,6 +152,29 @@ public abstract class SerializerSession extends BeanSession { } } + @Override /* Session */ + public ObjectMap asMap() { + return super.asMap() + .append("SerializerSession", new ObjectMap() + .append("maxDepth", maxDepth) + .append("initialDepth", initialDepth) + .append("maxIndent", maxIndent) + .append("detectRecursions", detectRecursions) + .append("ignoreRecursions", ignoreRecursions) + .append("useWhitespace", useWhitespace) + .append("addBeanTypeProperties", addBeanTypeProperties) + .append("trimNulls", trimNulls) + .append("trimEmptyCollections", trimEmptyCollections) + .append("trimEmptyMaps", trimEmptyMaps) + .append("trimStrings", trimStrings) + .append("sortCollections", sortCollections) + .append("sortMaps", sortMaps) + .append("abridged", abridged) + .append("quoteChar", quoteChar) + .append("uriResolver", uriResolver) + ); + } + /** * Wraps the specified input object into a {@link ParserPipe} object so that it can be easily converted into * a stream or reader. http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/dc5d9afb/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonParserSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonParserSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonParserSession.java index c4974cd..25c0b94 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonParserSession.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonParserSession.java @@ -54,13 +54,21 @@ public class UonParserSession extends ReaderParserSession { protected UonParserSession(UonParserContext ctx, ParserSessionArgs args) { super(ctx, args); ObjectMap p = getProperties(); - if (p.isEmpty()) { + if (! p.containsKeyPrefix(UonParserContext.PREFIX)) { decodeChars = ctx.decodeChars; } else { decodeChars = p.getBoolean(UON_decodeChars, ctx.decodeChars); } } + @Override /* Session */ + public ObjectMap asMap() { + return super.asMap() + .append("UonParser", new ObjectMap() + .append("decodeChars", decodeChars) + ); + } + /** * Create a specialized parser session for parsing URL parameters. * http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/dc5d9afb/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonSerializerContext.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonSerializerContext.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonSerializerContext.java index 952259b..6ce10e4 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonSerializerContext.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonSerializerContext.java @@ -121,8 +121,10 @@ public class UonSerializerContext extends SerializerContext { final boolean encodeChars, - addBeanTypeProperties, - plainTextParams; + addBeanTypeProperties; + + final String + paramFormat; /** * Constructor. @@ -137,7 +139,7 @@ public class UonSerializerContext extends SerializerContext { encodeChars = ps.getProperty(UON_encodeChars, boolean.class, false); addBeanTypeProperties = ps.getProperty(UON_addBeanTypeProperties, boolean.class, ps.getProperty(SERIALIZER_addBeanTypeProperties, boolean.class, true)); - plainTextParams = ps.getProperty(UON_paramFormat, String.class, "UON").equals("PLAINTEXT"); + paramFormat = ps.getProperty(UON_paramFormat, String.class, "UON"); } @Override /* Context */ @@ -146,16 +148,16 @@ public class UonSerializerContext extends SerializerContext { .append("UonSerializerContext", new ObjectMap() .append("encodeChars", encodeChars) .append("addBeanTypeProperties", addBeanTypeProperties) - .append("plainTextParams", plainTextParams) + .append("paramFormat", paramFormat) ); } /** - * Returns <jk>true</jk> if the {@link UonSerializerContext#UON_paramFormat} is <js>"PLAINTEXT"</js>. + * Returns the value of the {@link UonSerializerContext#UON_paramFormat} setting. * - * @return <jk>true</jk> if the {@link UonSerializerContext#UON_paramFormat} is <js>"PLAINTEXT"</js>. + * @return The value of the {@link UonSerializerContext#UON_paramFormat} setting. */ - public boolean plainTextParams() { - return plainTextParams; + public String getParamFormat() { + return paramFormat; } } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/dc5d9afb/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonSerializerSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonSerializerSession.java index 7730f1b..d8ae0d2 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonSerializerSession.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonSerializerSession.java @@ -12,7 +12,6 @@ // *************************************************************************************************************************** package org.apache.juneau.uon; -import static org.apache.juneau.msgpack.MsgPackSerializerContext.*; import static org.apache.juneau.uon.UonSerializerContext.*; import java.util.*; @@ -50,17 +49,27 @@ public class UonSerializerSession extends WriterSerializerSession { public UonSerializerSession(UonSerializerContext ctx, Boolean encode, SerializerSessionArgs args) { super(ctx, args); ObjectMap p = getProperties(); - if (p.isEmpty()) { + if (! p.containsKeyPrefix(UonSerializerContext.PREFIX)) { encodeChars = encode == null ? ctx.encodeChars : encode; addBeanTypeProperties = ctx.addBeanTypeProperties; - plainTextParams = ctx.plainTextParams; + plainTextParams = ctx.paramFormat.equals("PLAINTEXT"); } else { encodeChars = encode == null ? p.getBoolean(UON_encodeChars, ctx.encodeChars) : encode; - addBeanTypeProperties = p.getBoolean(MSGPACK_addBeanTypeProperties, ctx.addBeanTypeProperties); - plainTextParams = p.getString(UonSerializerContext.UON_paramFormat, "UON").equals("PLAINTEXT"); + addBeanTypeProperties = p.getBoolean(UON_addBeanTypeProperties, ctx.addBeanTypeProperties); + plainTextParams = p.getString(UonSerializerContext.UON_paramFormat, ctx.paramFormat).equals("PLAINTEXT"); } } + @Override /* Session */ + public ObjectMap asMap() { + return super.asMap() + .append("UonSerializerSession", new ObjectMap() + .append("addBeanTypeProperties", addBeanTypeProperties) + .append("encodeChars", encodeChars) + .append("plainTextParams", plainTextParams) + ); + } + /** * Returns the {@link UonSerializerContext#UON_addBeanTypeProperties} setting value for this session. * http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/dc5d9afb/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParserSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParserSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParserSession.java index 4f7409a..d8887f3 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParserSession.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingParserSession.java @@ -45,13 +45,21 @@ public class UrlEncodingParserSession extends UonParserSession { protected UrlEncodingParserSession(UrlEncodingParserContext ctx, ParserSessionArgs args) { super(ctx, args); ObjectMap p = getProperties(); - if (p.isEmpty()) { + if (! p.containsKeyPrefix(UrlEncodingParserContext.PREFIX)) { expandedParams = ctx.expandedParams; } else { - expandedParams = p.getBoolean(UrlEncodingParserContext.URLENC_expandedParams, false); + expandedParams = p.getBoolean(UrlEncodingParserContext.URLENC_expandedParams, ctx.expandedParams); } } + @Override /* Session */ + public ObjectMap asMap() { + return super.asMap() + .append("UrlEncodingParser", new ObjectMap() + .append("expandedParams", expandedParams) + ); + } + /** * Returns <jk>true</jk> if the specified bean property should be expanded as multiple key-value pairs. * http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/dc5d9afb/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializer.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializer.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializer.java index 65c800c..9889644 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializer.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializer.java @@ -259,7 +259,7 @@ public class UrlEncodingSerializer extends UonSerializer implements PartSerializ return o.toString(); if (cm.isCharSequence()) { String s = o.toString(); - boolean ptt = (plainTextParams != null ? plainTextParams : ctx.plainTextParams()); + boolean ptt = (plainTextParams != null ? plainTextParams : ctx.getParamFormat().equals("PLAINTEXT")); if (ptt || s.isEmpty() || ! UonUtils.needsQuotes(s)) return (urlEncode ? urlEncode(s) : s); } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/dc5d9afb/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.java index a800ad6..d5a2a3f 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/urlencoding/UrlEncodingSerializerSession.java @@ -51,13 +51,21 @@ public class UrlEncodingSerializerSession extends UonSerializerSession { protected UrlEncodingSerializerSession(UrlEncodingSerializerContext ctx, Boolean encode, SerializerSessionArgs args) { super(ctx, encode, args); ObjectMap p = getProperties(); - if (p.isEmpty()) { + if (! p.containsKeyPrefix(UrlEncodingSerializerContext.PREFIX)) { expandedParams = ctx.expandedParams; } else { - expandedParams = p.getBoolean(UrlEncodingSerializerContext.URLENC_expandedParams, false); + expandedParams = p.getBoolean(UrlEncodingSerializerContext.URLENC_expandedParams, ctx.expandedParams); } } + @Override /* Session */ + public ObjectMap asMap() { + return super.asMap() + .append("UrlEncodingSerializerSession", new ObjectMap() + .append("expandedParams", expandedParams) + ); + } + /* * Returns <jk>true</jk> if the specified bean property should be expanded as multiple key-value pairs. */ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/dc5d9afb/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserSession.java index 2b0cfcb..3351f1e 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserSession.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserSession.java @@ -61,7 +61,7 @@ public class XmlParserSession extends ReaderParserSession { protected XmlParserSession(XmlParserContext ctx, ParserSessionArgs args) { super(ctx, args); ObjectMap p = getProperties(); - if (p.isEmpty()) { + if (! p.containsKeyPrefix(XmlParserContext.PREFIX)) { validating = ctx.validating; reporter = ctx.reporter; resolver = ctx.resolver; @@ -76,6 +76,18 @@ public class XmlParserSession extends ReaderParserSession { } } + @Override /* Session */ + public ObjectMap asMap() { + return super.asMap() + .append("XmlParser", new ObjectMap() + .append("eventAllocator", eventAllocator) + .append("preserveRootElement", preserveRootElement) + .append("reporter", reporter) + .append("resolver", resolver) + .append("validating", validating) + ); + } + /** * Wrap the specified reader in a STAX reader based on settings in this context. * http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/dc5d9afb/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java index cf78f14..706acc1 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlSerializerSession.java @@ -68,7 +68,7 @@ public class XmlSerializerSession extends WriterSerializerSession { protected XmlSerializerSession(XmlSerializerContext ctx, SerializerSessionArgs args) { super(ctx, args); ObjectMap p = getProperties(); - if (p.isEmpty()) { + if (! p.containsKeyPrefix(XmlSerializerContext.PREFIX)) { enableNamespaces = ctx.enableNamespaces; autoDetectNamespaces = ctx.autoDetectNamespaces; addNamespaceUrlsToRoot = ctx.addNamespaceUrlsToRoot; @@ -87,6 +87,20 @@ public class XmlSerializerSession extends WriterSerializerSession { } } + @Override /* Session */ + public ObjectMap asMap() { + return super.asMap() + .append("XmlSerializerSession", new ObjectMap() + .append("addBeanTypeProperties", addBeanTypeProperties) + .append("addNamespaceUrlsToRoot", addNamespaceUrlsToRoot) + .append("autoDetectNamespaces", autoDetectNamespaces) + .append("defaultNamespace", defaultNamespace) + .append("enableNamespaces", enableNamespaces) + .append("namespaces", namespaces) + .append("xsNamespace", xsNamespace) + ); + } + private static Namespace findDefaultNamespace(String s) { if (s == null) return null; http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/dc5d9afb/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/yaml/proto/YamlSerializerSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/yaml/proto/YamlSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/yaml/proto/YamlSerializerSession.java index 1f252c9..3dd9b18 100644 --- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/yaml/proto/YamlSerializerSession.java +++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/yaml/proto/YamlSerializerSession.java @@ -55,6 +55,13 @@ public class YamlSerializerSession extends WriterSerializerSession { } } + @Override /* Session */ + public ObjectMap asMap() { + return super.asMap() + .append("YamlSerializerSession", new ObjectMap() + .append("addBeanTypeProperties", addBeanTypeProperties) + ); + } @Override /* SerializerSesssion */ protected void doSerialize(SerializerPipe out, Object o) throws Exception { http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/dc5d9afb/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestServletDefault.java ---------------------------------------------------------------------- diff --git a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestServletDefault.java b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestServletDefault.java index 1733d51..3d47e5d 100644 --- a/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestServletDefault.java +++ b/juneau-rest/juneau-rest-server/src/main/java/org/apache/juneau/rest/RestServletDefault.java @@ -13,6 +13,7 @@ package org.apache.juneau.rest; import static org.apache.juneau.http.HttpMethodName.*; +import static org.apache.juneau.serializer.SerializerContext.*; import org.apache.juneau.dto.swagger.*; import org.apache.juneau.html.*; @@ -182,6 +183,10 @@ import org.apache.juneau.xml.*; MsgPackParser.class, PlainTextParser.class }, + properties={ + // URI-resolution is disabled by default. Need to enable it. + @Property(name=SERIALIZER_uriResolution, value="ROOT_RELATIVE") + }, allowMethodParam="OPTIONS", htmldoc=@HtmlDoc( header={
