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/10/08 18:02:23 UTC
incubator-juneau git commit: Simplification of setting of
serializer/parser settings.
Repository: incubator-juneau
Updated Branches:
refs/heads/master dc5d9afb1 -> e4b78667f
Simplification of setting of 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/e4b78667
Tree: http://git-wip-us.apache.org/repos/asf/incubator-juneau/tree/e4b78667
Diff: http://git-wip-us.apache.org/repos/asf/incubator-juneau/diff/e4b78667
Branch: refs/heads/master
Commit: e4b78667f6c812c585575d008f24ec9e617da463
Parents: dc5d9af
Author: JamesBognar <ja...@apache.org>
Authored: Sun Oct 8 14:02:19 2017 -0400
Committer: JamesBognar <ja...@apache.org>
Committed: Sun Oct 8 14:02:19 2017 -0400
----------------------------------------------------------------------
.../java/org/apache/juneau/html/HtmlTest.java | 9 ++-
.../juneau/serializer/UriResolutionTest.java | 4 +-
.../apache/juneau/jena/RdfParserSession.java | 21 ++-----
.../juneau/jena/RdfSerializerSession.java | 44 +++++---------
.../java/org/apache/juneau/BeanSession.java | 2 +-
.../main/java/org/apache/juneau/ObjectMap.java | 37 ------------
.../java/org/apache/juneau/html/AnchorText.java | 62 ++++++++++++++++++++
.../juneau/html/HtmlSerializerBuilder.java | 23 ++------
.../juneau/html/HtmlSerializerContext.java | 36 ++----------
.../juneau/html/HtmlSerializerSession.java | 26 ++------
.../juneau/json/JsonSerializerSession.java | 12 +---
.../msgpack/MsgPackSerializerSession.java | 6 +-
.../org/apache/juneau/parser/ParserSession.java | 18 ++----
.../juneau/serializer/SerializerSession.java | 57 ++++++------------
.../java/org/apache/juneau/uon/ParamFormat.java | 44 ++++++++++++++
.../org/apache/juneau/uon/UonParserSession.java | 6 +-
.../apache/juneau/uon/UonSerializerBuilder.java | 26 ++++++++
.../apache/juneau/uon/UonSerializerContext.java | 27 ++-------
.../apache/juneau/uon/UonSerializerSession.java | 12 +---
.../urlencoding/UrlEncodingParserSession.java | 6 +-
.../UrlEncodingSerializerSession.java | 6 +-
.../org/apache/juneau/xml/XmlParserSession.java | 18 ++----
.../apache/juneau/xml/XmlSerializerSession.java | 31 +++-------
.../juneau/examples/rest/DirectoryResource.java | 2 +-
.../resources/DirectoryResource.java | 2 +-
.../microservice/resources/LogsResource.java | 2 +-
26 files changed, 229 insertions(+), 310 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e4b78667/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/html/HtmlTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/html/HtmlTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/html/HtmlTest.java
index 9d76201..6229b14 100755
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/html/HtmlTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/html/HtmlTest.java
@@ -12,7 +12,6 @@
// ***************************************************************************************************************************
package org.apache.juneau.html;
-import static org.apache.juneau.html.HtmlSerializerContext.*;
import static org.junit.Assert.*;
import java.util.*;
@@ -54,7 +53,7 @@ public class HtmlTest {
String r;
String expected = null;
- s.uriAnchorText(TO_STRING);
+ s.uriAnchorText(AnchorText.TO_STRING);
r = strip(s.build().serialize(t));
expected = ""
+"\n[f0]=<a href='f0/x0'>f0/x0</a>"
@@ -74,7 +73,7 @@ public class HtmlTest {
+"\n[fe]=<a href='http://www.apache.org/fe/xe?foo=bar&label2=MY_LABEL'>http://www.apache.org/fe/xe?foo=bar&label2=MY_LABEL</a>";
assertEquals(expected, r);
- s.uriAnchorText(URI);
+ s.uriAnchorText(AnchorText.URI);
r = strip(s.build().serialize(t));
expected = ""
+"\n[f0]=<a href='f0/x0'>f0/x0</a>"
@@ -94,7 +93,7 @@ public class HtmlTest {
+"\n[fe]=<a href='http://www.apache.org/fe/xe?foo=bar&label2=MY_LABEL'>http://www.apache.org/fe/xe?foo=bar&label2=MY_LABEL</a>";
assertEquals(expected, r);
- s.uriAnchorText(LAST_TOKEN);
+ s.uriAnchorText(AnchorText.LAST_TOKEN);
r = strip(s.build().serialize(t));
expected = ""
+"\n[f0]=<a href='f0/x0'>x0</a>"
@@ -114,7 +113,7 @@ public class HtmlTest {
+"\n[fe]=<a href='http://www.apache.org/fe/xe?foo=bar&label2=MY_LABEL'>xe</a>";
assertEquals(expected, r);
- s.uriAnchorText(URI_ANCHOR);
+ s.uriAnchorText(AnchorText.URI_ANCHOR);
r = strip(s.build().serialize(t));
expected = ""
+"\n[f0]=<a href='f0/x0'>f0/x0</a>"
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e4b78667/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/serializer/UriResolutionTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/serializer/UriResolutionTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/serializer/UriResolutionTest.java
index 5faf84c..f1c094d 100644
--- a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/serializer/UriResolutionTest.java
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/serializer/UriResolutionTest.java
@@ -617,13 +617,13 @@ public class UriResolutionTest {
@Test
public void c1_testHtmlSerialize() throws Exception {
- Serializer s = new HtmlSerializerBuilder().sq().lookForLabelParameters(true).uriAnchorText(HtmlSerializerContext.LAST_TOKEN).uriContext(input.context).uriResolution(input.resolution).uriRelativity(input.relativity).build();
+ Serializer s = new HtmlSerializerBuilder().sq().lookForLabelParameters(true).uriAnchorText(AnchorText.LAST_TOKEN).uriContext(input.context).uriResolution(input.resolution).uriRelativity(input.relativity).build();
testSerialize(s, results.html);
}
@Test
public void c2_testHtmlParse() throws Exception {
- Serializer s = new HtmlSerializerBuilder().sq().lookForLabelParameters(true).uriAnchorText(HtmlSerializerContext.LAST_TOKEN).uriContext(input.context).uriResolution(input.resolution).uriRelativity(input.relativity).build();
+ Serializer s = new HtmlSerializerBuilder().sq().lookForLabelParameters(true).uriAnchorText(AnchorText.LAST_TOKEN).uriContext(input.context).uriResolution(input.resolution).uriRelativity(input.relativity).build();
testParse(s, HtmlParser.DEFAULT);
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e4b78667/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 f9d9440..2365035 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,21 +59,12 @@ public class RdfParserSession extends ReaderParserSession {
ObjectMap jenaSettings = new ObjectMap();
jenaSettings.putAll(ctx.jenaSettings);
ObjectMap p = getProperties();
- if (! p.containsKeyPrefixes(RdfParserContext.PREFIX, "Rdf.")) {
- this.rdfLanguage = ctx.rdfLanguage;
- this.juneauNs = ctx.juneauNs;
- this.juneauBpNs = ctx.juneauBpNs;
- this.trimWhitespace = ctx.trimWhitespace;
- this.collectionFormat = ctx.collectionFormat;
- this.looseCollections = ctx.looseCollections;
- } else {
- this.rdfLanguage = p.getString(RDF_language, ctx.rdfLanguage);
- 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 = p.getWithDefault(RDF_collectionFormat, ctx.collectionFormat, RdfCollectionFormat.class);
- this.looseCollections = p.getBoolean(RDF_looseCollections, ctx.looseCollections);
- }
+ this.rdfLanguage = p.getString(RDF_language, ctx.rdfLanguage);
+ 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 = p.getWithDefault(RDF_collectionFormat, ctx.collectionFormat, RdfCollectionFormat.class);
+ this.looseCollections = p.getBoolean(RDF_looseCollections, ctx.looseCollections);
this.model = ModelFactory.createDefaultModel();
addModelPrefix(juneauNs);
addModelPrefix(juneauBpNs);
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e4b78667/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 918d405..3a6fb25 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,36 +71,22 @@ public final class RdfSerializerSession extends WriterSerializerSession {
jenaSettings.put("rdfXml.attributeQuoteChar", Character.toString(getQuoteChar()));
jenaSettings.putAll(ctx.jenaSettings);
ObjectMap p = getProperties();
- if (! p.containsKeyPrefixes(RdfSerializerContext.PREFIX, "Rdf.")) {
- this.rdfLanguage = ctx.rdfLanguage;
- this.juneauNs = ctx.juneauNs;
- this.juneauBpNs = ctx.juneauBpNs;
- this.addLiteralTypes = ctx.addLiteralTypes;
- this.addRootProperty = ctx.addRootProperty;
- this.collectionFormat = ctx.collectionFormat;
- this.looseCollections = ctx.looseCollections;
- this.useXmlNamespaces = ctx.useXmlNamespaces;
- this.autoDetectNamespaces = ctx.autoDetectNamespaces;
- this.namespaces = ctx.namespaces;
- addBeanTypeProperties = ctx.addBeanTypeProperties;
- } else {
- this.rdfLanguage = p.getString(RDF_language, ctx.rdfLanguage);
- 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.addLiteralTypes = p.getBoolean(RDF_addLiteralTypes, ctx.addLiteralTypes);
- this.addRootProperty = p.getBoolean(RDF_addRootProperty, ctx.addRootProperty);
- for (Map.Entry<String,Object> e : p.entrySet()) {
- String key = e.getKey();
- if (key.startsWith("Rdf.jena."))
- jenaSettings.put(key.substring(9), e.getValue());
- }
- 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);
- this.namespaces = p.getWithDefault(RDF_namespaces, ctx.namespaces, Namespace[].class);
- addBeanTypeProperties = p.getBoolean(RDF_addBeanTypeProperties, ctx.addBeanTypeProperties);
+ this.rdfLanguage = p.getString(RDF_language, ctx.rdfLanguage);
+ 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.addLiteralTypes = p.getBoolean(RDF_addLiteralTypes, ctx.addLiteralTypes);
+ this.addRootProperty = p.getBoolean(RDF_addRootProperty, ctx.addRootProperty);
+ for (Map.Entry<String,Object> e : p.entrySet()) {
+ String key = e.getKey();
+ if (key.startsWith("Rdf.jena."))
+ jenaSettings.put(key.substring(9), e.getValue());
}
+ 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);
+ this.namespaces = p.getWithDefault(RDF_namespaces, ctx.namespaces, Namespace[].class);
+ addBeanTypeProperties = p.getBoolean(RDF_addBeanTypeProperties, ctx.addBeanTypeProperties);
this.model = ModelFactory.createDefaultModel();
addModelPrefix(juneauNs);
addModelPrefix(juneauBpNs);
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e4b78667/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 b26c8bf..0a4d78d 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.containsKeyPrefix(BeanContext.PREFIX)) {
+ if (p == null) {
_locale = (args.locale != null ? args.locale : ctx.locale);
this.timeZone = (args.timeZone != null ? args.timeZone : ctx.timeZone);
this.debug = ctx.debug;
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e4b78667/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 4fc6927..e3ab9bc 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
@@ -1180,43 +1180,6 @@ public class ObjectMap extends LinkedHashMap<String,Object> {
}
/**
- * Returns <jk>true</jk> if this map contains a key with the specified string prefix.
- *
- * @param prefix The string prefix.
- * @return <jk>true</jk> if this map contains a key with the specified string prefix.
- */
- public boolean containsKeyPrefix(String prefix) {
- for (String s : super.keySet())
- if (s.startsWith(prefix))
- return true;
- if (inner != null) {
- if (inner instanceof ObjectMap) {
- if (((ObjectMap)inner).containsKeyPrefix(prefix))
- return true;
- return false;
- }
- for (String s : inner.keySet())
- if (s.startsWith(prefix))
- return true;
- }
- return false;
- }
-
- /**
- * 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/e4b78667/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/AnchorText.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/AnchorText.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/AnchorText.java
new file mode 100644
index 0000000..8b2f7ce
--- /dev/null
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/AnchorText.java
@@ -0,0 +1,62 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.html;
+
+/**
+ * Identifies possible values for the {@link HtmlSerializerContext#HTML_uriAnchorText} setting.
+ */
+public enum AnchorText {
+
+ /**
+ * Set to the bean property name.
+ */
+ PROPERTY_NAME,
+
+ /**
+ * Set to whatever is returned by {@link #toString()} on the object.
+ */
+ TO_STRING,
+
+ /**
+ * Set to the URI value.
+ */
+ URI,
+
+ /**
+ * Set to the last token of the URI value.
+ */
+ LAST_TOKEN,
+
+ /**
+ * Set to the anchor of the URL.
+ *
+ * <p>
+ * (e.g. <js>"http://localhost:9080/foobar#anchorTextHere"</js>)
+ */
+ URI_ANCHOR,
+
+ /**
+ * Same as {@link #TO_STRING} but assumes it's a context-relative path.
+ */
+ CONTEXT_RELATIVE,
+
+ /**
+ * Same as {@link #TO_STRING} but assumes it's a servlet-relative path.
+ */
+ SERVLET_RELATIVE,
+
+ /**
+ * Same as {@link #TO_STRING} but assumes it's a path-relative path.
+ */
+ PATH_RELATIVE
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e4b78667/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerBuilder.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerBuilder.java
index 66df425..6acada7 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerBuilder.java
@@ -57,8 +57,8 @@ public class HtmlSerializerBuilder extends XmlSerializerBuilder {
*
* <ul>
* <li><b>Name:</b> <js>"HtmlSerializer.uriAnchorText"</js>
- * <li><b>Data type:</b> <code>String</code>
- * <li><b>Default:</b> <js>"toString"</js>
+ * <li><b>Data type:</b> <code>AnchorText</code>
+ * <li><b>Default:</b> <jsf>TO_STRING</jsf>
* <li><b>Session-overridable:</b> <jk>true</jk>
* </ul>
*
@@ -67,33 +67,18 @@ public class HtmlSerializerBuilder extends XmlSerializerBuilder {
* in HTML, this setting defines what to set the inner text to.
*
* <p>
- * Possible values:
- * <ul class='spaced-list'>
- * <li>
- * {@link HtmlSerializerContext#TO_STRING} / <js>"toString"</js> - Set to whatever is returned by
- * {@link #toString()} on the object.
- * <li>
- * {@link HtmlSerializerContext#URI} / <js>"uri"</js> - Set to the URI value.
- * <li>
- * {@link HtmlSerializerContext#LAST_TOKEN} / <js>"lastToken"</js> - Set to the last token of the URI value.
- * <li>
- * {@link HtmlSerializerContext#PROPERTY_NAME} / <js>"propertyName"</js> - Set to the bean property name.
- * <li>
- * {@link HtmlSerializerContext#URI_ANCHOR} / <js>"uriAnchor"</js> - Set to the anchor of the URL.
- * (e.g. <js>"http://localhost:9080/foobar#anchorTextHere"</js>)
- * </ul>
+ * See the {@link AnchorText} enum for possible values.
*
* <h5 class='section'>Notes:</h5>
* <ul>
* <li>This is equivalent to calling <code>property(<jsf>HTML_uriAnchorText</jsf>, value)</code>.
- * <li>This introduces a slight performance penalty.
* </ul>
*
* @param value The new value for this property.
* @return This object (for method chaining).
* @see HtmlSerializerContext#HTML_uriAnchorText
*/
- public HtmlSerializerBuilder uriAnchorText(String value) {
+ public HtmlSerializerBuilder uriAnchorText(AnchorText value) {
return property(HTML_uriAnchorText, value);
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e4b78667/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerContext.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerContext.java
index 0f3c03d..2749b51 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerContext.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerContext.java
@@ -48,8 +48,8 @@ public class HtmlSerializerContext extends XmlSerializerContext {
*
* <ul>
* <li><b>Name:</b> <js>"HtmlSerializer.uriAnchorText"</js>
- * <li><b>Data type:</b> <code>String</code>
- * <li><b>Default:</b> <js>"toString"</js>
+ * <li><b>Data type:</b> <code>AnchorText</code>
+ * <li><b>Default:</b> <jsf>TO_STRING</jsf>
* <li><b>Session-overridable:</b> <jk>true</jk>
* </ul>
*
@@ -58,36 +58,10 @@ public class HtmlSerializerContext extends XmlSerializerContext {
* <xt>></xt>text<xt></a></xt></code>) in HTML, this setting defines what to set the inner text to.
*
* <p>
- * Possible values:
- * <ul class='spaced-list'>
- * <li>
- * {@link #TO_STRING} / <js>"toString"</js> - Set to whatever is returned by {@link #toString()} on the
- * object.
- * <li>
- * {@link #URI} / <js>"uri"</js> - Set to the URI value.
- * <li>
- * {@link #LAST_TOKEN} / <js>"lastToken"</js> - Set to the last token of the URI value.
- * <li>
- * {@link #PROPERTY_NAME} / <js>"propertyName"</js> - Set to the bean property name.
- * <li>
- * {@link #URI_ANCHOR} / <js>"uriAnchor"</js> - Set to the anchor of the URL.
- * (e.g. <js>"http://localhost:9080/foobar#anchorTextHere"</js>)
- * </ul>
+ * See the {@link AnchorText} enum for possible values.
*/
public static final String HTML_uriAnchorText = PREFIX + "uriAnchorText";
- /** Constant for {@link HtmlSerializerContext#HTML_uriAnchorText} property. */
- public static final String PROPERTY_NAME = "PROPERTY_NAME";
- /** Constant for {@link HtmlSerializerContext#HTML_uriAnchorText} property. */
- public static final String TO_STRING = "TO_STRING";
- /** Constant for {@link HtmlSerializerContext#HTML_uriAnchorText} property. */
- public static final String URI = "URI";
- /** Constant for {@link HtmlSerializerContext#HTML_uriAnchorText} property. */
- public static final String LAST_TOKEN = "LAST_TOKEN";
- /** Constant for {@link HtmlSerializerContext#HTML_uriAnchorText} property. */
- public static final String URI_ANCHOR = "URI_ANCHOR";
-
-
/**
* <b>Configuration property:</b> Look for URLs in {@link String Strings}.
*
@@ -170,7 +144,7 @@ public class HtmlSerializerContext extends XmlSerializerContext {
public static final String HTML_addBeanTypeProperties = PREFIX + "addBeanTypeProperties";
- final String uriAnchorText;
+ final AnchorText uriAnchorText;
final boolean
lookForLabelParameters,
detectLinksInStrings,
@@ -188,7 +162,7 @@ public class HtmlSerializerContext extends XmlSerializerContext {
*/
public HtmlSerializerContext(PropertyStore ps) {
super(ps);
- uriAnchorText = ps.getProperty(HTML_uriAnchorText, String.class, TO_STRING);
+ uriAnchorText = ps.getProperty(HTML_uriAnchorText, AnchorText.class, AnchorText.TO_STRING);
lookForLabelParameters = ps.getProperty(HTML_lookForLabelParameters, Boolean.class, true);
detectLinksInStrings = ps.getProperty(HTML_detectLinksInStrings, Boolean.class, true);
labelParameter = ps.getProperty(HTML_labelParameter, String.class, "label");
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e4b78667/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 056f6f1..9e9ae42 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
@@ -46,11 +46,6 @@ public class HtmlSerializerSession extends XmlSerializerSession {
private final Pattern labelPattern;
- @SuppressWarnings("hiding")
- enum AnchorText {
- PROPERTY_NAME, TO_STRING, URI, LAST_TOKEN, URI_ANCHOR, CONTEXT_RELATIVE, SERVLET_RELATIVE, PATH_RELATIVE
- }
-
/**
* Create a new session using properties specified in the context.
*
@@ -67,21 +62,12 @@ public class HtmlSerializerSession extends XmlSerializerSession {
super(ctx, args);
String labelParameter;
ObjectMap p = getProperties();
- if (! p.containsKeyPrefix(HtmlSerializerContext.PREFIX)) {
- anchorText = Enum.valueOf(AnchorText.class, ctx.uriAnchorText);
- detectLinksInStrings = ctx.detectLinksInStrings;
- lookForLabelParameters = ctx.lookForLabelParameters;
- labelParameter = ctx.labelParameter;
- addKeyValueTableHeaders = ctx.addKeyValueTableHeaders;
- addBeanTypeProperties = ctx.addBeanTypeProperties;
- } else {
- anchorText = Enum.valueOf(AnchorText.class, p.getString(HTML_uriAnchorText, ctx.uriAnchorText));
- detectLinksInStrings = p.getBoolean(HTML_detectLinksInStrings, ctx.detectLinksInStrings);
- lookForLabelParameters = p.getBoolean(HTML_lookForLabelParameters, ctx.lookForLabelParameters);
- labelParameter = p.getString(HTML_labelParameter, ctx.labelParameter);
- addKeyValueTableHeaders = p.getBoolean(HTML_addKeyValueTableHeaders, ctx.addKeyValueTableHeaders);
- addBeanTypeProperties = p.getBoolean(HTML_addBeanTypeProperties, ctx.addBeanTypeProperties);
- }
+ anchorText = p.getWithDefault(HTML_uriAnchorText, ctx.uriAnchorText, AnchorText.class);
+ detectLinksInStrings = p.getBoolean(HTML_detectLinksInStrings, ctx.detectLinksInStrings);
+ lookForLabelParameters = p.getBoolean(HTML_lookForLabelParameters, ctx.lookForLabelParameters);
+ labelParameter = p.getString(HTML_labelParameter, ctx.labelParameter);
+ addKeyValueTableHeaders = p.getBoolean(HTML_addKeyValueTableHeaders, ctx.addKeyValueTableHeaders);
+ addBeanTypeProperties = p.getBoolean(HTML_addBeanTypeProperties, ctx.addBeanTypeProperties);
labelPattern = Pattern.compile("[\\?\\&]" + Pattern.quote(labelParameter) + "=([^\\&]*)");
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e4b78667/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 8718641..6762136 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,15 +50,9 @@ public class JsonSerializerSession extends WriterSerializerSession {
protected JsonSerializerSession(JsonSerializerContext ctx, SerializerSessionArgs args) {
super(ctx, args);
ObjectMap p = getProperties();
- if (! p.containsKeyPrefix(JsonSerializerContext.PREFIX)) {
- simpleMode = ctx.simpleMode;
- escapeSolidus = ctx.escapeSolidus;
- addBeanTypeProperties = ctx.addBeanTypeProperties;
- } else {
- simpleMode = p.getBoolean(JSON_simpleMode, ctx.simpleMode);
- escapeSolidus = p.getBoolean(JSON_escapeSolidus, ctx.escapeSolidus);
- addBeanTypeProperties = p.getBoolean(JSON_addBeanTypeProperties, ctx.addBeanTypeProperties);
- }
+ simpleMode = p.getBoolean(JSON_simpleMode, ctx.simpleMode);
+ escapeSolidus = p.getBoolean(JSON_escapeSolidus, ctx.escapeSolidus);
+ addBeanTypeProperties = p.getBoolean(JSON_addBeanTypeProperties, ctx.addBeanTypeProperties);
}
@Override /* Session */
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e4b78667/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 bc0e2ca..7dac725 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,11 +48,7 @@ public final class MsgPackSerializerSession extends OutputStreamSerializerSessio
protected MsgPackSerializerSession(MsgPackSerializerContext ctx, SerializerSessionArgs args) {
super(ctx, args);
ObjectMap p = getProperties();
- if (! p.containsKeyPrefix(MsgPackSerializerContext.PREFIX)) {
- addBeanTypeProperties = ctx.addBeanTypeProperties;
- } else {
- addBeanTypeProperties = p.getBoolean(MSGPACK_addBeanTypeProperties, ctx.addBeanTypeProperties);
- }
+ addBeanTypeProperties = p.getBoolean(MSGPACK_addBeanTypeProperties, ctx.addBeanTypeProperties);
}
@Override /* Session */
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e4b78667/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 0e884eb..44e4718 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,19 +59,11 @@ public abstract class ParserSession extends BeanSession {
ctx = ParserContext.DEFAULT;
Class<?> listenerClass;
ObjectMap p = getProperties();
- if (! p.containsKeyPrefix(ParserContext.PREFIX)) {
- trimStrings = ctx.trimStrings;
- strict = ctx.strict;
- inputStreamCharset = ctx.inputStreamCharset;
- fileCharset = ctx.fileCharset;
- listenerClass = ctx.listener;
- } else {
- trimStrings = p.getBoolean(PARSER_trimStrings, ctx.trimStrings);
- strict = p.getBoolean(PARSER_strict, ctx.strict);
- inputStreamCharset = p.getString(PARSER_inputStreamCharset, ctx.inputStreamCharset);
- fileCharset = p.getString(PARSER_fileCharset, ctx.fileCharset);
- listenerClass = p.getWithDefault(PARSER_listener, ctx.listener, Class.class);
- }
+ trimStrings = p.getBoolean(PARSER_trimStrings, ctx.trimStrings);
+ strict = p.getBoolean(PARSER_strict, ctx.strict);
+ inputStreamCharset = p.getString(PARSER_inputStreamCharset, ctx.inputStreamCharset);
+ fileCharset = p.getString(PARSER_fileCharset, ctx.fileCharset);
+ listenerClass = p.getWithDefault(PARSER_listener, ctx.listener, Class.class);
this.javaMethod = args.javaMethod;
this.outer = args.outer;
this.listener = newInstance(ParserListener.class, listenerClass);
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e4b78667/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 ae4a206..5a1ff58 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,45 +100,24 @@ public abstract class SerializerSession extends BeanSession {
UriRelativity uriRelativity;
Class<?> listenerClass;
ObjectMap p = getProperties();
- if (! p.containsKeyPrefix(SerializerContext.PREFIX)) {
- maxDepth = ctx.maxDepth;
- initialDepth = ctx.initialDepth;
- detectRecursions = ctx.detectRecursions;
- ignoreRecursions = ctx.ignoreRecursions;
- useWhitespace = ctx.useWhitespace;
- maxIndent = ctx.maxIndent;
- addBeanTypeProperties = ctx.addBeanTypeProperties;
- trimNulls = ctx.trimNulls;
- trimEmptyCollections = ctx.trimEmptyCollections;
- trimEmptyMaps = ctx.trimEmptyMaps;
- trimStrings = ctx.trimStrings;
- quoteChar = ctx.quoteChar;
- sortCollections = ctx.sortCollections;
- sortMaps = ctx.sortMaps;
- abridged = ctx.abridged;
- uriResolution = ctx.uriResolution;
- uriRelativity = ctx.uriRelativity;
- listenerClass = ctx.listener;
- } else {
- maxDepth = p.getInt(SERIALIZER_maxDepth, ctx.maxDepth);
- initialDepth = p.getInt(SERIALIZER_initialDepth, ctx.initialDepth);
- detectRecursions = p.getBoolean(SERIALIZER_detectRecursions, ctx.detectRecursions);
- ignoreRecursions = p.getBoolean(SERIALIZER_ignoreRecursions, ctx.ignoreRecursions);
- useWhitespace = p.getBoolean(SERIALIZER_useWhitespace, ctx.useWhitespace);
- maxIndent = p.getInt(SERIALIZER_maxIndent, ctx.maxIndent);
- addBeanTypeProperties = p.getBoolean(SERIALIZER_addBeanTypeProperties, ctx.addBeanTypeProperties);
- trimNulls = p.getBoolean(SERIALIZER_trimNullProperties, ctx.trimNulls);
- trimEmptyCollections = p.getBoolean(SERIALIZER_trimEmptyCollections, ctx.trimEmptyCollections);
- trimEmptyMaps = p.getBoolean(SERIALIZER_trimEmptyMaps, ctx.trimEmptyMaps);
- trimStrings = p.getBoolean(SERIALIZER_trimStrings, ctx.trimStrings);
- quoteChar = p.getString(SERIALIZER_quoteChar, ""+ctx.quoteChar).charAt(0);
- 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, ctx.uriResolution, UriResolution.class);
- uriRelativity = p.getWithDefault(SERIALIZER_uriRelativity, ctx.uriRelativity, UriRelativity.class);
- listenerClass = p.getWithDefault(SERIALIZER_listener, ctx.listener, Class.class);
- }
+ maxDepth = p.getInt(SERIALIZER_maxDepth, ctx.maxDepth);
+ initialDepth = p.getInt(SERIALIZER_initialDepth, ctx.initialDepth);
+ detectRecursions = p.getBoolean(SERIALIZER_detectRecursions, ctx.detectRecursions);
+ ignoreRecursions = p.getBoolean(SERIALIZER_ignoreRecursions, ctx.ignoreRecursions);
+ useWhitespace = p.getBoolean(SERIALIZER_useWhitespace, ctx.useWhitespace);
+ maxIndent = p.getInt(SERIALIZER_maxIndent, ctx.maxIndent);
+ addBeanTypeProperties = p.getBoolean(SERIALIZER_addBeanTypeProperties, ctx.addBeanTypeProperties);
+ trimNulls = p.getBoolean(SERIALIZER_trimNullProperties, ctx.trimNulls);
+ trimEmptyCollections = p.getBoolean(SERIALIZER_trimEmptyCollections, ctx.trimEmptyCollections);
+ trimEmptyMaps = p.getBoolean(SERIALIZER_trimEmptyMaps, ctx.trimEmptyMaps);
+ trimStrings = p.getBoolean(SERIALIZER_trimStrings, ctx.trimStrings);
+ quoteChar = p.getString(SERIALIZER_quoteChar, ""+ctx.quoteChar).charAt(0);
+ 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, ctx.uriResolution, UriResolution.class);
+ uriRelativity = p.getWithDefault(SERIALIZER_uriRelativity, ctx.uriRelativity, UriRelativity.class);
+ listenerClass = p.getWithDefault(SERIALIZER_listener, ctx.listener, Class.class);
uriResolver = new UriResolver(uriResolution, uriRelativity, args.uriContext == null ? ctx.uriContext : args.uriContext);
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e4b78667/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/ParamFormat.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/ParamFormat.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/ParamFormat.java
new file mode 100644
index 0000000..7c6e3a7
--- /dev/null
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/ParamFormat.java
@@ -0,0 +1,44 @@
+// ***************************************************************************************************************************
+// * 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.uon;
+
+/**
+ * Identifies the possible values for the {@link UonSerializerContext#UON_paramFormat} setting.
+ */
+public enum ParamFormat {
+
+ /**
+ * Use UON notation for values.
+ *
+ * <p>
+ * String values such as <js>"(foo='bar')"</js> will end up being quoted and escaped to <js>"'(foo=bar~'baz~')'"</js>.
+ *
+ * <p>
+ * Boolean strings (<js>"true"</js>/<js>"false"</js>) and numeric values (<js>"123"</js>) will also end up quoted
+ * (<js>"'true'"</js>, <js>"'false'"</js>, <js>"'123'"</js>.
+ */
+ UON,
+
+ /**
+ * Serialize as plain text.
+ *
+ * <p>
+ * Strings will never be quoted or escaped.
+ *
+ * <p>
+ * Note that this can cause errors during parsing if you're using the URL-encoding parser to parse the results since
+ * UON constructs won't be differentiable.
+ * However, this is not an issue if you're simply creating queries or form posts against 3rd-party interfaces.
+ */
+ PLAINTEXT;
+}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e4b78667/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 25c0b94..c24385a 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,11 +54,7 @@ public class UonParserSession extends ReaderParserSession {
protected UonParserSession(UonParserContext ctx, ParserSessionArgs args) {
super(ctx, args);
ObjectMap p = getProperties();
- if (! p.containsKeyPrefix(UonParserContext.PREFIX)) {
- decodeChars = ctx.decodeChars;
- } else {
- decodeChars = p.getBoolean(UON_decodeChars, ctx.decodeChars);
- }
+ decodeChars = p.getBoolean(UON_decodeChars, ctx.decodeChars);
}
@Override /* Session */
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e4b78667/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonSerializerBuilder.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonSerializerBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonSerializerBuilder.java
index 42ce35f..dd1d92c 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonSerializerBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/uon/UonSerializerBuilder.java
@@ -93,6 +93,32 @@ public class UonSerializerBuilder extends SerializerBuilder {
return encodeChars(true);
}
+ /**
+ * <b>Configuration property:</b> Format to use for query/form-data/header values.
+ *
+ * <ul>
+ * <li><b>Name:</b> <js>"UrlEncodingSerializer.paramFormat"</js>
+ * <li><b>Data type:</b> <code>ParamFormat</code>
+ * <li><b>Default:</b> <jsf>UON</jsf>
+ * <li><b>Session-overridable:</b> <jk>true</jk>
+ * </ul>
+ *
+ * <p>
+ * Specifies the format to use for URL GET parameter keys and values.
+ *
+ * <h5 class='section'>Notes:</h5>
+ * <ul>
+ * <li>This is equivalent to calling <code>property(<jsf>UON_paramFormat</jsf>, value)</code>.
+ * </ul>
+ *
+ * @param value The new value for this property.
+ * @return This object (for method chaining).
+ * @see UonSerializerContext#UON_paramFormat
+ */
+ public UonSerializerBuilder paramFormat(ParamFormat value) {
+ return property(UON_paramFormat, value);
+ }
+
@Override /* SerializerBuilder */
public UonSerializerBuilder maxDepth(int value) {
super.maxDepth(value);
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e4b78667/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 6ce10e4..612802b 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
@@ -91,30 +91,13 @@ public class UonSerializerContext extends SerializerContext {
*
* <ul>
* <li><b>Name:</b> <js>"UrlEncodingSerializer.paramFormat"</js>
- * <li><b>Data type:</b> <code>String</code>
- * <li><b>Default:</b> <js>"UON"</js>
+ * <li><b>Data type:</b> <code>ParamFormat</code>
+ * <li><b>Default:</b> <jsf>UON</jsf>
* <li><b>Session-overridable:</b> <jk>true</jk>
* </ul>
*
* <p>
* Specifies the format to use for URL GET parameter keys and values.
- *
- * <p>
- * The possible values are:
- * <ul class='spaced-list'>
- * <li>
- * <js>"UON"</js> (default) - Use UON notation for values.
- * <br>String values such as <js>"(foo='bar')"</js> will end up being quoted and escaped to <js>"'(foo=bar~'baz~')'"</js>.
- * <br>Boolean strings (<js>"true"</js>/<js>"false"</js>) and numeric values (<js>"123"</js>) will also end up
- * quoted (<js>"'true'"</js>, <js>"'false'"</js>, <js>"'123'"</js>.
- * <li>
- * <js>"PLAINTEXT"</js> (default) - Serialize as plain text.
- * <br>Strings will never be quoted or escaped.
- * <br>Note that this can cause errors during parsing if you're using the URL-encoding parser to parse
- * the results since UON constructs won't be differentiable.
- * <br>However, this is not an issue if you're simply creating queries or form posts against 3rd-party
- * interfaces.
- * </ul>
*/
public static final String UON_paramFormat = PREFIX + "paramFormat";
@@ -123,7 +106,7 @@ public class UonSerializerContext extends SerializerContext {
encodeChars,
addBeanTypeProperties;
- final String
+ final ParamFormat
paramFormat;
/**
@@ -139,7 +122,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));
- paramFormat = ps.getProperty(UON_paramFormat, String.class, "UON");
+ paramFormat = ps.getProperty(UON_paramFormat, ParamFormat.class, ParamFormat.UON);
}
@Override /* Context */
@@ -157,7 +140,7 @@ public class UonSerializerContext extends SerializerContext {
*
* @return The value of the {@link UonSerializerContext#UON_paramFormat} setting.
*/
- public String getParamFormat() {
+ public ParamFormat getParamFormat() {
return paramFormat;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e4b78667/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 d8ae0d2..db6eea2 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
@@ -49,15 +49,9 @@ public class UonSerializerSession extends WriterSerializerSession {
public UonSerializerSession(UonSerializerContext ctx, Boolean encode, SerializerSessionArgs args) {
super(ctx, args);
ObjectMap p = getProperties();
- if (! p.containsKeyPrefix(UonSerializerContext.PREFIX)) {
- encodeChars = encode == null ? ctx.encodeChars : encode;
- addBeanTypeProperties = ctx.addBeanTypeProperties;
- plainTextParams = ctx.paramFormat.equals("PLAINTEXT");
- } else {
- encodeChars = encode == null ? p.getBoolean(UON_encodeChars, ctx.encodeChars) : encode;
- addBeanTypeProperties = p.getBoolean(UON_addBeanTypeProperties, ctx.addBeanTypeProperties);
- plainTextParams = p.getString(UonSerializerContext.UON_paramFormat, ctx.paramFormat).equals("PLAINTEXT");
- }
+ encodeChars = encode == null ? p.getBoolean(UON_encodeChars, ctx.encodeChars) : encode;
+ addBeanTypeProperties = p.getBoolean(UON_addBeanTypeProperties, ctx.addBeanTypeProperties);
+ plainTextParams = p.getWithDefault(UonSerializerContext.UON_paramFormat, ctx.paramFormat, ParamFormat.class) == ParamFormat.PLAINTEXT;
}
@Override /* Session */
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e4b78667/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 d8887f3..90c71f6 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,11 +45,7 @@ public class UrlEncodingParserSession extends UonParserSession {
protected UrlEncodingParserSession(UrlEncodingParserContext ctx, ParserSessionArgs args) {
super(ctx, args);
ObjectMap p = getProperties();
- if (! p.containsKeyPrefix(UrlEncodingParserContext.PREFIX)) {
- expandedParams = ctx.expandedParams;
- } else {
- expandedParams = p.getBoolean(UrlEncodingParserContext.URLENC_expandedParams, ctx.expandedParams);
- }
+ expandedParams = p.getBoolean(UrlEncodingParserContext.URLENC_expandedParams, ctx.expandedParams);
}
@Override /* Session */
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e4b78667/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 d5a2a3f..ccc2798 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,11 +51,7 @@ public class UrlEncodingSerializerSession extends UonSerializerSession {
protected UrlEncodingSerializerSession(UrlEncodingSerializerContext ctx, Boolean encode, SerializerSessionArgs args) {
super(ctx, encode, args);
ObjectMap p = getProperties();
- if (! p.containsKeyPrefix(UrlEncodingSerializerContext.PREFIX)) {
- expandedParams = ctx.expandedParams;
- } else {
- expandedParams = p.getBoolean(UrlEncodingSerializerContext.URLENC_expandedParams, ctx.expandedParams);
- }
+ expandedParams = p.getBoolean(UrlEncodingSerializerContext.URLENC_expandedParams, ctx.expandedParams);
}
@Override /* Session */
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e4b78667/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 3351f1e..5041848 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,19 +61,11 @@ public class XmlParserSession extends ReaderParserSession {
protected XmlParserSession(XmlParserContext ctx, ParserSessionArgs args) {
super(ctx, args);
ObjectMap p = getProperties();
- if (! p.containsKeyPrefix(XmlParserContext.PREFIX)) {
- validating = ctx.validating;
- reporter = ctx.reporter;
- resolver = ctx.resolver;
- eventAllocator = ctx.eventAllocator;
- preserveRootElement = ctx.preserveRootElement;
- } else {
- validating = p.getBoolean(XML_validating, ctx.validating);
- reporter = (XMLReporter)p.getWithDefault(XML_reporter, ctx.reporter);
- resolver = (XMLResolver)p.getWithDefault(XML_resolver, ctx.resolver);
- eventAllocator = (XMLEventAllocator)p.getWithDefault(XML_eventAllocator, ctx.eventAllocator);
- preserveRootElement = p.getBoolean(XML_preserveRootElement, ctx.preserveRootElement);
- }
+ validating = p.getBoolean(XML_validating, ctx.validating);
+ reporter = p.getWithDefault(XML_reporter, ctx.reporter, XMLReporter.class);
+ resolver = p.getWithDefault(XML_resolver, ctx.resolver, XMLResolver.class);
+ eventAllocator = p.getWithDefault(XML_eventAllocator, ctx.eventAllocator, XMLEventAllocator.class);
+ preserveRootElement = p.getBoolean(XML_preserveRootElement, ctx.preserveRootElement);
}
@Override /* Session */
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e4b78667/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 706acc1..987836a 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
@@ -37,7 +37,7 @@ import org.apache.juneau.xml.annotation.*;
* This class is NOT thread safe.
* It is typically discarded after one-time use although it can be reused within the same thread.
*/
-@SuppressWarnings({"hiding","unchecked","rawtypes"})
+@SuppressWarnings({"unchecked","rawtypes"})
public class XmlSerializerSession extends WriterSerializerSession {
final boolean
@@ -68,23 +68,13 @@ public class XmlSerializerSession extends WriterSerializerSession {
protected XmlSerializerSession(XmlSerializerContext ctx, SerializerSessionArgs args) {
super(ctx, args);
ObjectMap p = getProperties();
- if (! p.containsKeyPrefix(XmlSerializerContext.PREFIX)) {
- enableNamespaces = ctx.enableNamespaces;
- autoDetectNamespaces = ctx.autoDetectNamespaces;
- addNamespaceUrlsToRoot = ctx.addNamespaceUrlsToRoot;
- addNamespaces(ctx.namespaces);
- defaultNamespace = findDefaultNamespace(ctx.defaultNamespace);
- xsNamespace = ctx.xsNamespace;
- addBeanTypeProperties = ctx.addBeanTypeProperties;
- } else {
- enableNamespaces = p.getBoolean(XML_enableNamespaces, ctx.enableNamespaces);
- autoDetectNamespaces = p.getBoolean(XML_autoDetectNamespaces, ctx.autoDetectNamespaces);
- addNamespaceUrlsToRoot = p.getBoolean(XML_addNamespaceUrisToRoot, ctx.addNamespaceUrlsToRoot);
- namespaces = (p.containsKey(XML_namespaces) ? parseNamespaces(p.get(XML_namespaces)) : ctx.namespaces);
- defaultNamespace = findDefaultNamespace(p.containsKey(XML_defaultNamespace) ? p.getString(XML_defaultNamespace) : ctx.defaultNamespace);
- xsNamespace = (p.containsKey(XML_xsNamespace) ? parseNamespace(p.get(XML_xsNamespace)) : ctx.xsNamespace);
- addBeanTypeProperties = p.getBoolean(MSGPACK_addBeanTypeProperties, ctx.addBeanTypeProperties);
- }
+ enableNamespaces = p.getBoolean(XML_enableNamespaces, ctx.enableNamespaces);
+ autoDetectNamespaces = p.getBoolean(XML_autoDetectNamespaces, ctx.autoDetectNamespaces);
+ addNamespaceUrlsToRoot = p.getBoolean(XML_addNamespaceUrisToRoot, ctx.addNamespaceUrlsToRoot);
+ namespaces = (p.containsKey(XML_namespaces) ? parseNamespaces(p.get(XML_namespaces)) : ctx.namespaces);
+ defaultNamespace = findDefaultNamespace(p.containsKey(XML_defaultNamespace) ? p.getString(XML_defaultNamespace) : ctx.defaultNamespace);
+ xsNamespace = (p.containsKey(XML_xsNamespace) ? parseNamespace(p.get(XML_xsNamespace)) : ctx.xsNamespace);
+ addBeanTypeProperties = p.getBoolean(XML_addBeanTypeProperties, ctx.addBeanTypeProperties);
}
@Override /* Session */
@@ -111,11 +101,6 @@ public class XmlSerializerSession extends WriterSerializerSession {
return get(null, s);
}
- private void addNamespaces(Namespace...namespaces) {
- for (Namespace ns : namespaces)
- addNamespace(ns);
- }
-
/*
* Add a namespace to this session.
*
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e4b78667/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DirectoryResource.java
----------------------------------------------------------------------
diff --git a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DirectoryResource.java b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DirectoryResource.java
index fcb6bb0..0dc280c 100644
--- a/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DirectoryResource.java
+++ b/juneau-examples/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/DirectoryResource.java
@@ -52,7 +52,7 @@ import org.apache.juneau.utils.*;
),
allowMethodParam="*",
properties={
- @Property(name=HTML_uriAnchorText, value=PROPERTY_NAME),
+ @Property(name=HTML_uriAnchorText, value="PROPERTY_NAME"),
@Property(name="rootDir", value="$S{java.io.tmpdir}"),
@Property(name="allowViews", value="false"),
@Property(name="allowDeletes", value="false"),
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e4b78667/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java
----------------------------------------------------------------------
diff --git a/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java b/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java
index 0e9890c..b131e2d 100755
--- a/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java
+++ b/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java
@@ -71,7 +71,7 @@ import org.apache.juneau.utils.*;
),
allowMethodParam="*",
properties={
- @Property(name=HTML_uriAnchorText, value=PROPERTY_NAME),
+ @Property(name=HTML_uriAnchorText, value="PROPERTY_NAME"),
@Property(name="DirectoryResource.rootDir", value="")
}
)
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/e4b78667/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/resources/LogsResource.java
----------------------------------------------------------------------
diff --git a/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/resources/LogsResource.java b/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/resources/LogsResource.java
index f02458b..811c928 100755
--- a/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/resources/LogsResource.java
+++ b/juneau-microservice/juneau-microservice-server/src/main/java/org/apache/juneau/microservice/resources/LogsResource.java
@@ -42,7 +42,7 @@ import org.apache.juneau.transforms.*;
title="Log files",
description="Log files from this service",
properties={
- @Property(name=HTML_uriAnchorText, value=PROPERTY_NAME),
+ @Property(name=HTML_uriAnchorText, value="PROPERTY_NAME"),
},
allowMethodParam="*",
pojoSwaps={