http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/jena/RdfParserContext.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/jena/RdfParserContext.java b/juneau-core/src/main/java/org/apache/juneau/jena/RdfParserContext.java index 91aa7c9..9f047ad 100644 --- a/juneau-core/src/main/java/org/apache/juneau/jena/RdfParserContext.java +++ b/juneau-core/src/main/java/org/apache/juneau/jena/RdfParserContext.java @@ -37,18 +37,48 @@ import org.apache.juneau.xml.*; * <p> * See {@link ContextFactory} for more information about context properties. * + * + * <h6 class='topic' id='ConfigProperties'>Configurable properties on the RDF parsers</h6> + * <table class='styled' style='border-collapse: collapse;'> + * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr> + * <tr> + * <td>{@link #RDF_trimWhitespace}</td> + * <td>Trim whitespace from text elements.</td> + * <td><code>Boolean</code></td> + * <td><jk>false</jk></td> + * </tr> + * </table> + * + * <h6 class='topic' id='ConfigProperties'>Configurable properties inherited by the RDF parsers</h6> + * <ul class='javahierarchy'> + * <li class='c'><a class='doclink' href='../BeanContext.html#ConfigProperties'>BeanContext</a> - Properties associated with handling beans on serializers and parsers. + * <ul> + * <li class='c'><a class='doclink' href='../parser/ParserContext.html#ConfigProperties'>ParserContext</a> - Configurable properties common to all parsers. + * <ul> + * <li class='i'><a class='doclink' href='RdfCommonContext.html#ConfigProperties'>RdfCommonContext</a> - Configurable properties common to the RDF serializers and parsers. + * </ul> + * </ul> + * </ul> + * + * * @author James Bognar ([email protected]) */ public final class RdfParserContext extends ParserContext implements RdfCommonContext { /** - * Trim whitespace from text elements ({@link Boolean}, default=<jk>false</jk>). + * <b>Configuration property:</b> Trim whitespace from text elements. + * <p> + * <ul> + * <li><b>Name:</b> <js>"RdfParser.trimWhitespace"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * </ul> * <p> * If <jk>true</jk>, whitespace in text elements will be automatically trimmed. */ public static final String RDF_trimWhitespace = "RdfParser.trimWhitespace"; - final boolean trimWhitespace, looseCollection; + final boolean trimWhitespace, looseCollections; final String rdfLanguage; final Namespace juneauNs, juneauBpNs; final RdfCollectionFormat collectionFormat; @@ -64,7 +94,7 @@ public final class RdfParserContext extends ParserContext implements RdfCommonCo public RdfParserContext(ContextFactory cf) { super(cf); trimWhitespace = cf.getProperty(RDF_trimWhitespace, boolean.class, false); - looseCollection = cf.getProperty(RDF_looseCollection, boolean.class, false); + looseCollections = cf.getProperty(RDF_looseCollections, boolean.class, false); rdfLanguage = cf.getProperty(RDF_language, String.class, "RDF/XML-ABBREV"); juneauNs = cf.getProperty(RDF_juneauNs, Namespace.class, new Namespace("j", "http://www.ibm.com/juneau/")); juneauBpNs = cf.getProperty(RDF_juneauBpNs, Namespace.class, new Namespace("j", "http://www.ibm.com/juneaubp/"));
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/jena/RdfParserSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/jena/RdfParserSession.java b/juneau-core/src/main/java/org/apache/juneau/jena/RdfParserSession.java index a493e36..e7cfce9 100644 --- a/juneau-core/src/main/java/org/apache/juneau/jena/RdfParserSession.java +++ b/juneau-core/src/main/java/org/apache/juneau/jena/RdfParserSession.java @@ -38,7 +38,7 @@ public class RdfParserSession extends ParserSession { private final Namespace juneauNs, juneauBpNs; private final Property pRoot, pValue, pClass, pType; private final Model model; - private final boolean trimWhitespace, looseCollection; + private final boolean trimWhitespace, looseCollections; private final RDFReader rdfReader; private final Set<Resource> urisVisited = new HashSet<Resource>(); private final RdfCollectionFormat collectionFormat; @@ -72,14 +72,14 @@ public class RdfParserSession extends ParserSession { this.juneauBpNs = ctx.juneauBpNs; this.trimWhitespace = ctx.trimWhitespace; this.collectionFormat = ctx.collectionFormat; - this.looseCollection = ctx.looseCollection; + this.looseCollections = ctx.looseCollections; } else { this.rdfLanguage = op.getString(RDF_language, ctx.rdfLanguage); this.juneauNs = (op.containsKey(RDF_juneauNs) ? NamespaceFactory.parseNamespace(op.get(RDF_juneauNs)) : ctx.juneauNs); this.juneauBpNs = (op.containsKey(RDF_juneauBpNs) ? NamespaceFactory.parseNamespace(op.get(RDF_juneauBpNs)) : ctx.juneauBpNs); this.trimWhitespace = op.getBoolean(RdfParserContext.RDF_trimWhitespace, ctx.trimWhitespace); this.collectionFormat = RdfCollectionFormat.valueOf(op.getString(RDF_collectionFormat, "DEFAULT")); - this.looseCollection = op.getBoolean(RDF_looseCollection, ctx.looseCollection); + this.looseCollections = op.getBoolean(RDF_looseCollections, ctx.looseCollections); } this.model = ModelFactory.createDefaultModel(); addModelPrefix(juneauNs); @@ -171,12 +171,12 @@ public class RdfParserSession extends ParserSession { } /** - * Returns the {@link RdfCommonContext#RDF_looseCollection} setting value for this session. + * Returns the {@link RdfCommonContext#RDF_looseCollections} setting value for this session. * - * @return The {@link RdfCommonContext#RDF_looseCollection} setting value for this session. + * @return The {@link RdfCommonContext#RDF_looseCollections} setting value for this session. */ - public final boolean isLooseCollection() { - return looseCollection; + public final boolean isLooseCollections() { + return looseCollections; } /** http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializer.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializer.java b/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializer.java index 0ac2a62..a9beabb 100644 --- a/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializer.java +++ b/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializer.java @@ -131,7 +131,7 @@ public class RdfSerializer extends WriterSerializer { Resource r = null; ClassMeta<?> cm = s.getBeanContext().getClassMetaForObject(o); - if (s.isLooseCollection() && cm != null && (cm.isCollection() || cm.isArray())) { + if (s.isLooseCollections() && cm != null && (cm.isCollection() || cm.isArray())) { Collection c = s.sort(cm.isCollection() ? (Collection)o : toList(cm.getInnerClass(), o)); for (Object o2 : c) serializeAnything(s, o2, false, object(), "root", null, null); http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializerContext.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializerContext.java b/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializerContext.java index 5dd4bfa..6819f66 100644 --- a/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializerContext.java +++ b/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializerContext.java @@ -37,17 +37,71 @@ import org.apache.juneau.xml.*; * <p> * See {@link ContextFactory} for more information about context properties. * + * + * <h6 class='topic' id='ConfigProperties'>Configurable properties on the RDF serializers</h6> + * <table class='styled' style='border-collapse: collapse;'> + * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr> + * <tr> + * <td>{@link #RDF_addLiteralTypes}</td> + * <td>Add XSI data types to non-<code>String</code> literals.</td> + * <td><code>Boolean</code></td> + * <td><jk>false</jk></td> + * </tr> + * <tr> + * <td>{@link #RDF_addRootProperty}</td> + * <td>Add RDF root identifier property to root node.</td> + * <td><code>Boolean</code></td> + * <td><jk>false</jk></td> + * </tr> + * <tr> + * <td>{@link #RDF_autoDetectNamespaces}</td> + * <td>Auto-detect namespace usage.</td> + * <td><code>Boolean</code></td> + * <td><jk>true</jk></td> + * </tr> + * <tr> + * <td>{@link #RDF_namespaces}</td> + * <td>Default namespaces.</td> + * <td><code>List<{@link Namespace}></code></td> + * <td>empty list</td> + * </tr> + * </table> + * + * <h6 class='topic' id='ConfigProperties'>Configurable properties inherited by the RDF serializers</h6> + * <ul class='javahierarchy'> + * <li class='c'><a class='doclink' href='../BeanContext.html#ConfigProperties'>BeanContext</a> - Properties associated with handling beans on serializers and parsers. + * <ul> + * <li class='c'><a class='doclink' href='../serializer/SerializerContext.html#ConfigProperties'>SerializerContext</a> - Configurable properties common to all serializers. + * <ul> + * <li class='c'><a class='doclink' href='RdfCommonContext.html#ConfigProperties'>RdfCommonContext</a> - Configurable properties common to the RDF serializers and parsers. + * </ul> + * </ul> + * </ul> + * + * * @author James Bognar ([email protected]) */ public final class RdfSerializerContext extends SerializerContext implements RdfCommonContext { /** - * Add XSI data types to non-<code>String</code> literals ({@link Boolean}, default=<jk>false</jk>). + * <b>Configuration property:</b> Add XSI data types to non-<code>String</code> literals. + * <p> + * <ul> + * <li><b>Name:</b> <js>"RdfSerializer.addLiteralTypes"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * </ul> */ public static final String RDF_addLiteralTypes = "RdfSerializer.addLiteralTypes"; /** - * Add RDF root identifier property to root node ({@link Boolean}, default=<jk>false</jk>). + * <b>Configuration property:</b> Add RDF root identifier property to root node. + * <p> + * <ul> + * <li><b>Name:</b> <js>"RdfSerializer.addRootProperty"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * </ul> * <p> * When enabled an RDF property <code>http://www.ibm.com/juneau/root</code> is added with a value of <js>"true"</js> * to identify the root node in the graph. @@ -60,7 +114,13 @@ public final class RdfSerializerContext extends SerializerContext implements Rdf public static final String RDF_addRootProperty = "RdfSerializer.addRootProperty"; /** - * Auto-detect namespace usage ({@link Boolean}, default=<jk>true</jk>). + * <b>Configuration property:</b> Auto-detect namespace usage. + * <p> + * <ul> + * <li><b>Name:</b> <js>"RdfSerializer.autoDetectNamespaces"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>true</jk> + * </ul> * <p> * Detect namespace usage before serialization. * <p> @@ -71,14 +131,20 @@ public final class RdfSerializerContext extends SerializerContext implements Rdf public static final String RDF_autoDetectNamespaces = "RdfSerializer.autoDetectNamespaces"; /** - * Default namespaces (<code>List<Namespace></code>, default=<code>Namespace[0]</code>). + * <b>Configuration property:</b> Default namespaces. + * <p> + * <ul> + * <li><b>Name:</b> <js>"RdfSerializer.namespaces.list"</js> + * <li><b>Data type:</b> <code>List<{@link Namespace}></code> + * <li><b>Default:</b> empty list + * </ul> * <p> * The default list of namespaces associated with this serializer. */ public static final String RDF_namespaces = "RdfSerializer.namespaces.list"; - final boolean addLiteralTypes, addRootProperty, useXmlNamespaces, looseCollection, autoDetectNamespaces; + final boolean addLiteralTypes, addRootProperty, useXmlNamespaces, looseCollections, autoDetectNamespaces; final String rdfLanguage; final Namespace juneauNs; final Namespace juneauBpNs; @@ -98,7 +164,7 @@ public final class RdfSerializerContext extends SerializerContext implements Rdf addLiteralTypes = cf.getProperty(RDF_addLiteralTypes, boolean.class, false); addRootProperty = cf.getProperty(RDF_addRootProperty, boolean.class, false); useXmlNamespaces = cf.getProperty(RDF_useXmlNamespaces, boolean.class, true); - looseCollection = cf.getProperty(RDF_looseCollection, boolean.class, false); + looseCollections = cf.getProperty(RDF_looseCollections, boolean.class, false); autoDetectNamespaces = cf.getProperty(RDF_autoDetectNamespaces, boolean.class, true); rdfLanguage = cf.getProperty(RDF_language, String.class, "RDF/XML-ABBREV"); juneauNs = cf.getProperty(RDF_juneauNs, Namespace.class, new Namespace("j", "http://www.ibm.com/juneau/")); http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java index b4fa7aa..a1a73e7 100644 --- a/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java +++ b/juneau-core/src/main/java/org/apache/juneau/jena/RdfSerializerSession.java @@ -37,7 +37,7 @@ public final class RdfSerializerSession extends SerializerSession { private final String rdfLanguage; private final Namespace juneauNs, juneauBpNs; - private final boolean addLiteralTypes, addRootProperty, useXmlNamespaces, looseCollection, autoDetectNamespaces; + private final boolean addLiteralTypes, addRootProperty, useXmlNamespaces, looseCollections, autoDetectNamespaces; private final Property pRoot, pValue, pClass; private final Model model; private final RDFWriter writer; @@ -68,7 +68,7 @@ public final class RdfSerializerSession extends SerializerSession { this.addLiteralTypes = ctx.addLiteralTypes; this.addRootProperty = ctx.addRootProperty; this.collectionFormat = ctx.collectionFormat; - this.looseCollection = ctx.looseCollection; + this.looseCollections = ctx.looseCollections; this.useXmlNamespaces = ctx.useXmlNamespaces; this.autoDetectNamespaces = ctx.autoDetectNamespaces; this.namespaces = ctx.namespaces; @@ -84,7 +84,7 @@ public final class RdfSerializerSession extends SerializerSession { jenaSettings.put(key.substring(9), e.getValue()); } this.collectionFormat = RdfCollectionFormat.valueOf(op.getString(RDF_collectionFormat, "DEFAULT")); - this.looseCollection = op.getBoolean(RDF_looseCollection, ctx.looseCollection); + this.looseCollections = op.getBoolean(RDF_looseCollections, ctx.looseCollections); this.useXmlNamespaces = op.getBoolean(RDF_useXmlNamespaces, ctx.useXmlNamespaces); this.autoDetectNamespaces = op.getBoolean(RDF_autoDetectNamespaces, ctx.autoDetectNamespaces); this.namespaces = op.get(Namespace[].class, RDF_namespaces, ctx.namespaces); @@ -137,12 +137,12 @@ public final class RdfSerializerSession extends SerializerSession { } /** - * Returns the {@link RdfCommonContext#RDF_looseCollection} setting value for this session. + * Returns the {@link RdfCommonContext#RDF_looseCollections} setting value for this session. * - * @return The {@link RdfCommonContext#RDF_looseCollection} setting value for this session. + * @return The {@link RdfCommonContext#RDF_looseCollections} setting value for this session. */ - public final boolean isLooseCollection() { - return looseCollection; + public final boolean isLooseCollections() { + return looseCollections; } /** http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/jena/package.html ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/jena/package.html b/juneau-core/src/main/java/org/apache/juneau/jena/package.html index 0a25043..2a08529 100644 --- a/juneau-core/src/main/java/org/apache/juneau/jena/package.html +++ b/juneau-core/src/main/java/org/apache/juneau/jena/package.html @@ -372,7 +372,7 @@ <jk>public class</jk> Person { <jc>// Bean properties</jc> - <ja>@BeanProperty</ja>(beanUri=<jk>true</jk>) + <ja>@Rdf</ja>(beanUri=<jk>true</jk>) <jk>public</jk> URI <jf>uri</jf>; <jk>public</jk> URI <jf>addressBookUri</jf>; @@ -414,7 +414,7 @@ <p> The {@link org.apache.juneau.annotation.URI} annotation can also be used on classes and properties to identify them as URLs when they're not instances of <code>java.net.URI</code> or <code>java.net.URL</code> - (not needed if <code><ja>@BeanProperty</ja>(beanUri=<jk>true</jk>)</code> is already specified). + (not needed if <code><ja>@Rdf</ja>(beanUri=<jk>true</jk>)</code> is already specified). </p> <p> The following properties would have produced the same output as before. Note that the <ja>@URI</ja> annotation is only needed @@ -424,7 +424,7 @@ <jk>public class</jk> Person { <jc>// Bean properties</jc> - <ja>@BeanProperty</ja>(beanUri=<jk>true</jk>) <jk>public</jk> String <jf>uri</jf>; + <ja>@Rdf</ja>(beanUri=<jk>true</jk>) <jk>public</jk> String <jf>uri</jf>; <ja>@URI</ja> <jk>public</jk> String <jf>addressBookUri</jf>; </p> @@ -478,7 +478,7 @@ <jk>public class</jk> Person { <jc>// Bean properties</jc> - <ja>@BeanProperty</ja>(transform=CalendarSwap.ISO8601DTZ.<jk>class</jk>) <jk>public</jk> Calendar birthDate; + <ja>@BeanProperty</ja>(swap=CalendarSwap.ISO8601DTZ.<jk>class</jk>) <jk>public</jk> Calendar birthDate; ... <jc>// Normal constructor</jc> @@ -540,7 +540,7 @@ <jk>public class</jk> Address { <jc>// Bean properties</jc> - <ja>@BeanProperty</ja>(beanUri=<jk>true</jk>) <jk>public</jk> URI <jf>uri</jf>; + <ja>@Rdf</ja>(beanUri=<jk>true</jk>) <jk>public</jk> URI <jf>uri</jf>; <jk>public</jk> URI <jf>personUri</jf>; <jk>public int</jk> <jf>id</jf>; http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/json/JsonParserContext.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/json/JsonParserContext.java b/juneau-core/src/main/java/org/apache/juneau/json/JsonParserContext.java index 5a37d4a..0801000 100644 --- a/juneau-core/src/main/java/org/apache/juneau/json/JsonParserContext.java +++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonParserContext.java @@ -34,12 +34,38 @@ import org.apache.juneau.parser.*; * <p> * See {@link ContextFactory} for more information about context properties. * + * + * <h6 class='topic' id='ConfigProperties'>Configurable properties on the JSON parser</h6> + * <table class='styled' style='border-collapse: collapse;'> + * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr> + * <tr> + * <td>{@link #JSON_strictMode}</td> + * <td>Strict mode</td> + * <td><code>Boolean</code></td> + * <td><jk>false</jk></td> + * </tr> + * </table> + * + * <h6 class='topic'>Configurable properties inherited from parent classes</h6> + * <ul class='javahierarchy'> + * <li class='c'><a class='doclink' href='../BeanContext.html#ConfigProperties'>BeanContext</a> - Properties associated with handling beans on serializers and parsers. + * <ul> + * <li class='c'><a class='doclink' href='../parser/ParserContext.html#ConfigProperties'>ParserContext</a> - Configurable properties common to all parsers. + * </ul> + * </ul> + * * @author James Bognar ([email protected]) */ public final class JsonParserContext extends ParserContext { /** - * Set strict mode ({@link Boolean}, default=<jk>false</jk>). + * <b>Configuration property:</b> Strict mode. + * <p> + * <ul> + * <li><b>Name:</b> <js>"JsonParser.strictMode"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * </ul> * <p> * When in strict mode, parser throws exceptions on the following invalid JSON syntax: * <ul class='spaced-list'> http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerContext.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerContext.java b/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerContext.java index cf41764..e8d0144 100644 --- a/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerContext.java +++ b/juneau-core/src/main/java/org/apache/juneau/json/JsonSerializerContext.java @@ -34,12 +34,51 @@ import org.apache.juneau.serializer.*; * <p> * See {@link ContextFactory} for more information about context properties. * + * + * <h6 class='topic' id='ConfigProperties'>Configurable properties on the JSON serializer</h6> + * <table class='styled' style='border-collapse: collapse;'> + * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr> + * <tr> + * <td>{@link #JSON_simpleMode}</td> + * <td>Simple JSON mode.</td> + * <td><code>Boolean</code></td> + * <td><jk>false</jk></td> + * </tr> + * <tr> + * <td>{@link #JSON_useWhitespace}</td> + * <td>Use whitespace.</td> + * <td><code>Boolean</code></td> + * <td><jk>false</jk></td> + * </tr> + * <tr> + * <td>{@link #JSON_escapeSolidus}</td> + * <td>Prefix solidus <js>'/'</js> characters with escapes.</td> + * <td><code>Boolean</code></td> + * <td><jk>false</jk></td> + * </tr> + * </table> + * + * <h6 class='topic'>Configurable properties inherited from parent classes</h6> + * <ul class='javahierarchy'> + * <li class='c'><a class='doclink' href='../BeanContext.html#ConfigProperties'>BeanContext</a> - Properties associated with handling beans on serializers and parsers. + * <ul> + * <li class='c'><a class='doclink' href='../serializer/SerializerContext.html#ConfigProperties'>SerializerContext</a> - Configurable properties common to all serializers. + * </ul> + * </ul> + * + * * @author James Bognar ([email protected]) */ public final class JsonSerializerContext extends SerializerContext { /** - * Simple JSON mode ({@link Boolean}, default=<jk>false</jk>). + * <b>Configuration property:</b> Simple JSON mode. + * <p> + * <ul> + * <li><b>Name:</b> <js>"JsonSerializer.simpleMode"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * </ul> * <p> * If <jk>true</jk>, JSON attribute names will only be quoted when necessary. * Otherwise, they are always quoted. @@ -47,14 +86,26 @@ public final class JsonSerializerContext extends SerializerContext { public static final String JSON_simpleMode = "JsonSerializer.simpleMode"; /** - * Use whitespace in output ({@link Boolean}, default=<jk>false</jk>). + * <b>Configuration property:</b> Use whitespace. + * <p> + * <ul> + * <li><b>Name:</b> <js>"JsonSerializer.useWhitespace"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * </ul> * <p> * If <jk>true</jk>, whitespace is added to the output to improve readability. */ public static final String JSON_useWhitespace = "JsonSerializer.useWhitespace"; /** - * Prefix solidus <js>'/'</js> characters with escapes ({@link Boolean}, default=<jk>false</jk>). + * <b>Configuration property:</b> Prefix solidus <js>'/'</js> characters with escapes. + * <p> + * <ul> + * <li><b>Name:</b> <js>"JsonSerializer.escapeSolidus"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * </ul> * <p> * If <jk>true</jk>, solidus (e.g. slash) characters should be escaped. * The JSON specification allows for either format. http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/json/package.html ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/json/package.html b/juneau-core/src/main/java/org/apache/juneau/json/package.html index 2012db3..4c16767 100644 --- a/juneau-core/src/main/java/org/apache/juneau/json/package.html +++ b/juneau-core/src/main/java/org/apache/juneau/json/package.html @@ -324,7 +324,7 @@ <jk>public</jk> URI <jf>uri</jf>; <jk>public</jk> URI <jf>addressBookUri</jf>; - <ja>@BeanProperty</ja>(transform=CalendarSwap.ISO8601DTZ.<jk>class</jk>) <jk>public</jk> Calendar <jf>birthDate</jf>; + <ja>@BeanProperty</ja>(swap=CalendarSwap.ISO8601DTZ.<jk>class</jk>) <jk>public</jk> Calendar <jf>birthDate</jf>; <jc>// Bean constructor (needed by parser)</jc> @@ -487,7 +487,7 @@ <jk>public</jk> String <jf>name</jf>; <jk>public</jk> URI <jf>uri</jf>; <jk>public</jk> URI <jf>addressBookUri</jf>; - <ja>@BeanProperty</ja>(transform=CalendarSwap.ISO8601DTZ.<jk>class</jk>) <jk>public</jk> Calendar <jf>birthDate</jf>; + <ja>@BeanProperty</ja>(swap=CalendarSwap.ISO8601DTZ.<jk>class</jk>) <jk>public</jk> Calendar <jf>birthDate</jf>; <jk>public</jk> LinkedList<Address> <jf>addresses</jf> = <jk>new</jk> LinkedList<Address>(); <jc>// Bean constructor (needed by parser)</jc> http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParserContext.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParserContext.java b/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParserContext.java index 2d7d4dc..8d4556c 100644 --- a/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParserContext.java +++ b/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackParserContext.java @@ -34,6 +34,20 @@ import org.apache.juneau.parser.*; * <p> * See {@link ContextFactory} for more information about context properties. * + * + * <h6 class='topic' id='ConfigProperties'>Configurable properties on the MessagePack parser</h6> + * <table class='styled' style='border-collapse: collapse;'> + * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr> + * </table> + * + * <h6 class='topic'>Configurable properties inherited from parent classes</h6> + * <ul class='javahierarchy'> + * <li class='c'><a class='doclink' href='../BeanContext.html#ConfigProperties'>BeanContext</a> - Properties associated with handling beans on serializers and parsers. + * <ul> + * <li class='c'><a class='doclink' href='../parser/ParserContext.html#ConfigProperties'>ParserContext</a> - Configurable properties common to all parsers. + * </ul> + * </ul> + * * @author James Bognar ([email protected]) */ public final class MsgPackParserContext extends ParserContext { http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerContext.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerContext.java b/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerContext.java index fcc9f0d..e354c4f 100644 --- a/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerContext.java +++ b/juneau-core/src/main/java/org/apache/juneau/msgpack/MsgPackSerializerContext.java @@ -34,6 +34,19 @@ import org.apache.juneau.serializer.*; * <p> * See {@link ContextFactory} for more information about context properties. * + * + * <h6 class='topic' id='ConfigProperties'>Configurable properties on the MessagePack serializer</h6> + * <p> + * None. + * + * <h6 class='topic'>Configurable properties inherited from parent classes</h6> + * <ul class='javahierarchy'> + * <li class='c'><a class='doclink' href='../BeanContext.html#ConfigProperties'>BeanContext</a> - Properties associated with handling beans on serializers and parsers. + * <ul> + * <li class='c'><a class='doclink' href='../serializer/SerializerContext.html#ConfigProperties'>SerializerContext</a> - Configurable properties common to all serializers. + * </ul> + * </ul> + * * @author James Bognar ([email protected]) */ public final class MsgPackSerializerContext extends SerializerContext { http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/parser/ParserContext.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/parser/ParserContext.java b/juneau-core/src/main/java/org/apache/juneau/parser/ParserContext.java index 9100cb3..a6920aa 100644 --- a/juneau-core/src/main/java/org/apache/juneau/parser/ParserContext.java +++ b/juneau-core/src/main/java/org/apache/juneau/parser/ParserContext.java @@ -15,14 +15,39 @@ package org.apache.juneau.parser; import org.apache.juneau.*; /** - * Parent class for all parser contexts. + * Configurable properties common to all parsers. + * + * + * <h6 class='topic' id='ConfigProperties'>Configurable properties common to all parsers</h6> + * <table class='styled' style='border-collapse: collapse;'> + * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr> + * <tr> + * <td>{@link #PARSER_debug}</td> + * <td>Debug mode.</td> + * <td><code>Boolean</code></td> + * <td><jk>false</jk></td> + * </tr> + * <tr> + * <td>{@link #PARSER_trimStrings}</td> + * <td>Trim parsed strings.</td> + * <td><code>Boolean</code></td> + * <td><jk>false</jk></td> + * </tr> + * </table> + * * * @author James Bognar ([email protected]) */ public class ParserContext extends Context { /** - * Debug mode ({@link Boolean}, default=<jk>false</jk>). + * <b>Configuration property:</b> Debug mode. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Parser.debug"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * </ul> * <p> * Enables the following additional information during parsing: * <ul class='spaced-list'> @@ -33,7 +58,13 @@ public class ParserContext extends Context { public static final String PARSER_debug = "Parser.debug"; /** - * Trim parsed strings ({@link Boolean}, default=<jk>false</jk>). + * <b>Configuration property:</b> Trim parsed strings. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Parser.trimStrings"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * </ul> * <p> * If <jk>true</jk>, string values will be trimmed of whitespace using {@link String#trim()} before being added to the POJO. */ @@ -44,8 +75,6 @@ public class ParserContext extends Context { /** * Constructor. - * <p> - * Typically only called from {@link ContextFactory#getContext(Class)}. * * @param cf The factory that created this context. */ http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerContext.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerContext.java b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerContext.java index ff3b2cf..c4a67d5 100644 --- a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerContext.java +++ b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerContext.java @@ -16,14 +16,123 @@ import org.apache.juneau.*; import org.apache.juneau.internal.*; /** - * Parent class for all serializer contexts. + * Configurable properties common to all serializers. + * + * + * <h6 class='topic' id='ConfigProperties'>Configurable properties common to all serializers</h6> + * <table class='styled' style='border-collapse: collapse;'> + * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr> + * <tr> + * <td>{@link #SERIALIZER_maxDepth}</td> + * <td>Max serialization depth.</td> + * <td><code>Integer</code></td> + * <td><code>100</code></td> + * </tr> + * <tr> + * <td>{@link #SERIALIZER_initialDepth}</td> + * <td>Initial depth.</td> + * <td><code>Integer</code></td> + * <td><code>0</code></td> + * </tr> + * <tr> + * <td>{@link #SERIALIZER_detectRecursions}</td> + * <td>Automatically detect POJO recursions.</td> + * <td><code>Boolean</code></td> + * <td><jk>false</jk></td> + * </tr> + * <tr> + * <td>{@link #SERIALIZER_ignoreRecursions}</td> + * <td>Ignore recursion errors.</td> + * <td><code>Boolean</code></td> + * <td><jk>false</jk></td> + * </tr> + * <tr> + * <td>{@link #SERIALIZER_debug}</td> + * <td>Debug mode.</td> + * <td><code>Boolean</code></td> + * <td><jk>false</jk></td> + * </tr> + * <tr> + * <td>{@link #SERIALIZER_useIndentation}</td> + * <td>Use indentation.</td> + * <td><code>Boolean</code></td> + * <td><jk>false</jk></td> + * </tr> + * <tr> + * <td>{@link #SERIALIZER_addBeanTypeProperties}</td> + * <td>Add <js>"_type"</js> properties when needed.</td> + * <td><code>Boolean</code></td> + * <td><jk>false</jk></td> + * </tr> + * <tr> + * <td>{@link #SERIALIZER_quoteChar}</td> + * <td>Quote character.</td> + * <td><code>Character</code></td> + * <td><js>'"'</js></td> + * </tr> + * <tr> + * <td>{@link #SERIALIZER_trimNullProperties}</td> + * <td>Trim null bean property values.</td> + * <td><code>Boolean</code></td> + * <td><jk>true</jk></td> + * </tr> + * <tr> + * <td>{@link #SERIALIZER_trimEmptyCollections}</td> + * <td>Trim empty lists and arrays.</td> + * <td><code>Boolean</code></td> + * <td><jk>false</jk></td> + * </tr> + * <tr> + * <td>{@link #SERIALIZER_trimEmptyMaps}</td> + * <td>Trim empty maps.</td> + * <td><code>Boolean</code></td> + * <td><jk>false</jk></td> + * </tr> + * <tr> + * <td>{@link #SERIALIZER_trimStrings}</td> + * <td>Trim strings.</td> + * <td><code>Boolean</code></td> + * <td><jk>false</jk></td> + * </tr> + * <tr> + * <td>{@link #SERIALIZER_relativeUriBase}</td> + * <td>URI base for relative URIs.</td> + * <td><code>String</code></td> + * <td><js>""</js></td> + * </tr> + * <tr> + * <td>{@link #SERIALIZER_absolutePathUriBase}</td> + * <td>URI base for relative URIs with absolute paths.</td> + * <td><code>String</code></td> + * <td><js>""</js></td> + * </tr> + * <tr> + * <td>{@link #SERIALIZER_sortCollections}</td> + * <td>Sort arrays and collections alphabetically.</td> + * <td><code>Boolean</code></td> + * <td><jk>false</jk></td> + * </tr> + * <tr> + * <td>{@link #SERIALIZER_sortMaps}</td> + * <td>Sort maps alphabetically.</td> + * <td><code>Boolean</code></td> + * <td><jk>false</jk></td> + * </tr> + * </table> + * * * @author James Bognar ([email protected]) */ public class SerializerContext extends Context { /** - * Max serialization depth ({@link Integer}, default=<code>100</code>). + * <b>Configuration property:</b> Max serialization depth. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.maxDepth"</js> + * <li><b>Data type:</b> <code>Integer</code> + * <li><b>Default:</b> <code>100</code> + * </ul> * <p> * Abort serialization if specified depth is reached in the POJO tree. * If this depth is exceeded, an exception is thrown. @@ -32,7 +141,13 @@ public class SerializerContext extends Context { public static final String SERIALIZER_maxDepth = "Serializer.maxDepth"; /** - * Initial depth ({@link Integer}, default=<code>0</code>). + * <b>Configuration property:</b> Initial depth. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.initialDepth"</js> + * <li><b>Data type:</b> <code>Integer</code> + * <li><b>Default:</b> <code>0</code> + * </ul> * <p> * The initial indentation level at the root. * Useful when constructing document fragments that need to be indented at a certain level. @@ -40,7 +155,13 @@ public class SerializerContext extends Context { public static final String SERIALIZER_initialDepth = "Serializer.initialDepth"; /** - * Automatically detect POJO recursions ({@link Boolean}, default=<jk>false</jk>). + * <b>Configuration property:</b> Automatically detect POJO recursions. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.detectRecursions"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * </ul> * <p> * Specifies that recursions should be checked for during serialization. * <p> @@ -57,7 +178,13 @@ public class SerializerContext extends Context { public static final String SERIALIZER_detectRecursions = "Serializer.detectRecursions"; /** - * Ignore recursion errors ({@link Boolean}, default=<jk>false</jk>). + * <b>Configuration property:</b> Ignore recursion errors. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.ignoreRecursions"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * </ul> * <p> * Used in conjunction with {@link #SERIALIZER_detectRecursions}. * Setting is ignored if <jsf>SERIALIZER_detectRecursions</jsf> is <jk>false</jk>. @@ -69,7 +196,13 @@ public class SerializerContext extends Context { public static final String SERIALIZER_ignoreRecursions = "Serializer.ignoreRecursions"; /** - * Debug mode ({@link Boolean}, default=<jk>false</jk>). + * <b>Configuration property:</b> Debug mode. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.debug"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * </ul> * <p> * Enables the following additional information during serialization: * <ul class='spaced-list'> @@ -81,14 +214,26 @@ public class SerializerContext extends Context { public static final String SERIALIZER_debug = "Serializer.debug"; /** - * Use indentation in output ({@link Boolean}, default=<jk>false</jk>). + * <b>Configuration property:</b> Use indentation. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.useIndentation"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * </ul> * <p> * If <jk>true</jk>, newlines and indentation is added to the output to improve readability. */ public static final String SERIALIZER_useIndentation = "Serializer.useIndentation"; /** - * Add <js>"_type"</js> properties to output when needed.({@link Boolean}, default=<jk>false</jk>). + * <b>Configuration property:</b> Add <js>"_type"</js> properties when needed. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.addBeanTypeProperties"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * </ul> * <p> * If <jk>true</jk>, then <js>"_type"</js> properties will be added to beans if their type cannot be inferred through reflection. * This is used to recreate the correct objects during parsing if the object types cannot be inferred. @@ -97,14 +242,26 @@ public class SerializerContext extends Context { public static final String SERIALIZER_addBeanTypeProperties = "Serializer.addBeanTypeProperties"; /** - * Quote character ({@link Character}, default=<js>'"'</js>). + * <b>Configuration property:</b> Quote character. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.quoteChar"</js> + * <li><b>Data type:</b> <code>Character</code> + * <li><b>Default:</b> <js>'"'</js> + * </ul> * <p> * This is the character used for quoting attributes and values. */ public static final String SERIALIZER_quoteChar = "Serializer.quoteChar"; /** - * Trim null bean property values from output ({@link Boolean}, default=<jk>true</jk>). + * <b>Configuration property:</b> Trim null bean property values. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.trimNullProperties"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>true</jk> + * </ul> * <p> * If <jk>true</jk>, null bean values will not be serialized to the output. * <p> @@ -116,7 +273,13 @@ public class SerializerContext extends Context { public static final String SERIALIZER_trimNullProperties = "Serializer.trimNullProperties"; /** - * Trim empty lists and arrays from output ({@link Boolean}, default=<jk>false</jk>). + * <b>Configuration property:</b> Trim empty lists and arrays. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.trimEmptyLists"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * </ul> * <p> * If <jk>true</jk>, empty list values will not be serialized to the output. * <p> @@ -126,10 +289,16 @@ public class SerializerContext extends Context { * <li>Bean properties with empty list values will not be set. * </ul> */ - public static final String SERIALIZER_trimEmptyLists = "Serializer.trimEmptyLists"; + public static final String SERIALIZER_trimEmptyCollections = "Serializer.trimEmptyLists"; /** - * Trim empty maps from output ({@link Boolean}, default=<jk>false</jk>). + * <b>Configuration property:</b> Trim empty maps. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.trimEmptyMaps"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * </ul> * <p> * If <jk>true</jk>, empty map values will not be serialized to the output. * <p> @@ -141,14 +310,26 @@ public class SerializerContext extends Context { public static final String SERIALIZER_trimEmptyMaps = "Serializer.trimEmptyMaps"; /** - * Trim strings in output ({@link Boolean}, default=<jk>false</jk>). + * <b>Configuration property:</b> Trim strings. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.trimStrings"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * </ul> * <p> * If <jk>true</jk>, string values will be trimmed of whitespace using {@link String#trim()} before being serialized. */ public static final String SERIALIZER_trimStrings = "Serializer.trimStrings"; /** - * URI base for relative URIs ({@link String}, default=<js>""</js>). + * <b>Configuration property:</b> URI base for relative URIs. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.relativeUriBase"</js> + * <li><b>Data type:</b> <code>String</code> + * <li><b>Default:</b> <js>""</js> + * </ul> * <p> * Prepended to relative URIs during serialization (along with the {@link #SERIALIZER_absolutePathUriBase} if specified. * (i.e. URIs not containing a schema and not starting with <js>'/'</js>). @@ -181,21 +362,13 @@ public class SerializerContext extends Context { public static final String SERIALIZER_relativeUriBase = "Serializer.relativeUriBase"; /** - * Sort arrays and collections alphabetically before serializing ({@link Boolean}, default=<jk>false</jk>). + * <b>Configuration property:</b> URI base for relative URIs with absolute paths. * <p> - * Note that this introduces a performance penalty. - */ - public static final String SERIALIZER_sortCollections = "Serializer.sortCollections"; - - /** - * Sort maps alphabetically before serializing ({@link Boolean}, default=<jk>false</jk>). - * <p> - * Note that this introduces a performance penalty. - */ - public static final String SERIALIZER_sortMaps = "Serializer.sortMaps"; - - /** - * URI base for relative URIs with absolute paths ({@link String}, default=<js>""</js>). + * <ul> + * <li><b>Name:</b> <js>"Serializer.absolutePathUriBase"</js> + * <li><b>Data type:</b> <code>String</code> + * <li><b>Default:</b> <js>""</js> + * </ul> * <p> * Prepended to relative absolute-path URIs during serialization. * (i.e. URIs starting with <js>'/'</js>). @@ -227,6 +400,32 @@ public class SerializerContext extends Context { */ public static final String SERIALIZER_absolutePathUriBase = "Serializer.absolutePathUriBase"; + /** + * <b>Configuration property:</b> Sort arrays and collections alphabetically. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.sortCollections"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * </ul> + * <p> + * Note that this introduces a performance penalty. + */ + public static final String SERIALIZER_sortCollections = "Serializer.sortCollections"; + + /** + * <b>Configuration property:</b> Sort maps alphabetically. + * <p> + * <ul> + * <li><b>Name:</b> <js>"Serializer.sortMaps"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * </ul> + * <p> + * Note that this introduces a performance penalty. + */ + public static final String SERIALIZER_sortMaps = "Serializer.sortMaps"; + final int maxDepth, initialDepth; final boolean @@ -236,7 +435,7 @@ public class SerializerContext extends Context { useIndentation, addBeanTypeProperties, trimNulls, - trimEmptyLists, + trimEmptyCollections, trimEmptyMaps, trimStrings, sortCollections, @@ -246,8 +445,6 @@ public class SerializerContext extends Context { /** * Constructor. - * <p> - * Typically only called from {@link ContextFactory#getContext(Class)}. * * @param cf The factory that created this context. */ @@ -261,7 +458,7 @@ public class SerializerContext extends Context { useIndentation = cf.getProperty(SERIALIZER_useIndentation, boolean.class, false); addBeanTypeProperties = cf.getProperty(SERIALIZER_addBeanTypeProperties, boolean.class, false); trimNulls = cf.getProperty(SERIALIZER_trimNullProperties, boolean.class, true); - trimEmptyLists = cf.getProperty(SERIALIZER_trimEmptyLists, boolean.class, false); + trimEmptyCollections = cf.getProperty(SERIALIZER_trimEmptyCollections, boolean.class, false); trimEmptyMaps = cf.getProperty(SERIALIZER_trimEmptyMaps, boolean.class, false); trimStrings = cf.getProperty(SERIALIZER_trimStrings, boolean.class, false); sortCollections = cf.getProperty(SERIALIZER_sortCollections, boolean.class, false); http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java index 49aefe7..7821542 100644 --- a/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java +++ b/juneau-core/src/main/java/org/apache/juneau/serializer/SerializerSession.java @@ -51,7 +51,7 @@ public class SerializerSession extends Session { useIndentation, addBeanTypeProperties, trimNulls, - trimEmptyLists, + trimEmptyCollections, trimEmptyMaps, trimStrings, sortCollections, @@ -115,7 +115,7 @@ public class SerializerSession extends Session { useIndentation = ctx.useIndentation; addBeanTypeProperties = ctx.addBeanTypeProperties; trimNulls = ctx.trimNulls; - trimEmptyLists = ctx.trimEmptyLists; + trimEmptyCollections = ctx.trimEmptyCollections; trimEmptyMaps = ctx.trimEmptyMaps; trimStrings = ctx.trimStrings; quoteChar = ctx.quoteChar; @@ -133,7 +133,7 @@ public class SerializerSession extends Session { useIndentation = op.getBoolean(SERIALIZER_useIndentation, ctx.useIndentation); addBeanTypeProperties = op.getBoolean(SERIALIZER_addBeanTypeProperties, ctx.addBeanTypeProperties); trimNulls = op.getBoolean(SERIALIZER_trimNullProperties, ctx.trimNulls); - trimEmptyLists = op.getBoolean(SERIALIZER_trimEmptyLists, ctx.trimEmptyLists); + trimEmptyCollections = op.getBoolean(SERIALIZER_trimEmptyCollections, ctx.trimEmptyCollections); trimEmptyMaps = op.getBoolean(SERIALIZER_trimEmptyMaps, ctx.trimEmptyMaps); trimStrings = op.getBoolean(SERIALIZER_trimStrings, ctx.trimStrings); quoteChar = op.getString(SERIALIZER_quoteChar, ""+ctx.quoteChar).charAt(0); @@ -347,12 +347,12 @@ public class SerializerSession extends Session { } /** - * Returns the {@link SerializerContext#SERIALIZER_trimEmptyLists} setting value for this session. + * Returns the {@link SerializerContext#SERIALIZER_trimEmptyCollections} setting value for this session. * - * @return The {@link SerializerContext#SERIALIZER_trimEmptyLists} setting value for this session. + * @return The {@link SerializerContext#SERIALIZER_trimEmptyCollections} setting value for this session. */ - public final boolean isTrimEmptyLists() { - return trimEmptyLists; + public final boolean isTrimEmptyCollections() { + return trimEmptyCollections; } /** @@ -563,7 +563,7 @@ public class SerializerSession extends Session { if (cm == null) cm = getBeanContext().object(); - if (trimEmptyLists) { + if (trimEmptyCollections) { if (cm.isArray() || (cm.isObject() && value.getClass().isArray())) { if (((Object[])value).length == 0) return true; http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializerContext.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializerContext.java b/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializerContext.java index ca57a29..bebfcd5 100644 --- a/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializerContext.java +++ b/juneau-core/src/main/java/org/apache/juneau/soap/SoapXmlSerializerContext.java @@ -12,17 +12,41 @@ // *************************************************************************************************************************** package org.apache.juneau.soap; + /** * Properties associated with the {@link SoapXmlSerializer} class. * + * <h6 class='topic' id='ConfigProperties'>Configurable properties on the SOAP/XML serializer</h6> + * <table class='styled' style='border-collapse: collapse;'> + * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr> + * <tr> + * <td>{@link #SOAPXML_SOAPAction}</td> + * <td>The <code>SOAPAction</code> HTTP header value to set on responses.</td> + * <td><code>String</code></td> + * <td><js>"http://www.w3.org/2003/05/soap-envelope"</js></td> + * </tr> + * </table> + * + * <h6 class='topic'>Configurable properties inherited from parent classes</h6> + * <ul class='javahierarchy'> + * <li class='c'><a class='doclink' href='../BeanContext.html#ConfigProperties'>BeanContext</a> - Properties associated with handling beans on serializers and parsers. + * <ul> + * <li class='c'><a class='doclink' href='../serializer/SerializerContext.html#ConfigProperties'>SerializerContext</a> - Configurable properties common to all serializers. + * </ul> + * </ul> + * * @author James Bognar ([email protected]) */ public final class SoapXmlSerializerContext { /** - * The <code>SOAPAction</code> HTTP header value to set on responses. + * <b>Configuration property:</b> The <code>SOAPAction</code> HTTP header value to set on responses. * <p> - * Default is <js>"http://www.w3.org/2003/05/soap-envelope"</js>. + * <ul> + * <li><b>Name:</b> <js>"SoapXmlSerializer.SOAPAction"</js> + * <li><b>Data type:</b> <code>String</code> + * <li><b>Default:</b> <js>"http://www.w3.org/2003/05/soap-envelope"</js> + * </ul> */ public static final String SOAPXML_SOAPAction = "SoapXmlSerializer.SOAPAction"; } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/svl/vars/package.html ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/svl/vars/package.html b/juneau-core/src/main/java/org/apache/juneau/svl/vars/package.html new file mode 100644 index 0000000..5344cc6 --- /dev/null +++ b/juneau-core/src/main/java/org/apache/juneau/svl/vars/package.html @@ -0,0 +1,41 @@ +<!DOCTYPE HTML> +<!-- +/*************************************************************************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + ***************************************************************************************************************************/ + --> +<html> +<head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <style type="text/css"> + /* For viewing in Page Designer */ + @IMPORT url("../../../../../../../javadoc.css"); + + /* For viewing in REST interface */ + @IMPORT url("../htdocs/javadoc.css"); + body { + margin: 20px; + } + </style> + <script> + /* Replace all @code and @link tags. */ + window.onload = function() { + document.body.innerHTML = document.body.innerHTML.replace(/\{\@code ([^\}]+)\}/g, '<code>$1</code>'); + document.body.innerHTML = document.body.innerHTML.replace(/\{\@link (([^\}]+)\.)?([^\.\}]+)\}/g, '<code>$3</code>'); + } + </script> +</head> +<body> +<p>Simple Variable Language - Predefined variables</p> +</body> +</html> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonParserContext.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonParserContext.java b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonParserContext.java index f64b800..2446341 100644 --- a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonParserContext.java +++ b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonParserContext.java @@ -34,12 +34,45 @@ import org.apache.juneau.parser.*; * <p> * See {@link ContextFactory} for more information about context properties. * + * + * <h6 class='topic' id='ConfigProperties'>Configurable properties on the URL-Encoding and UON parsers</h6> + * <table class='styled' style='border-collapse: collapse;'> + * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr> + * <tr> + * <td>{@link #UON_decodeChars}</td> + * <td>Decode <js>"%xx"</js> sequences</td> + * <td><code>Boolean</code></td> + * <td><jk>false</jk> for {@link UonParser}<br><jk>true</jk> for {@link UrlEncodingParser}</td> + * </tr> + * <tr> + * <td>{@link #UON_whitespaceAware}</td> + * <td>Whitespace aware</td> + * <td><code>Boolean</code></td> + * <td><jk>false</jk></td> + * </tr> + * </table> + * + * <h6 class='topic'>Configurable properties inherited from parent classes</h6> + * <ul class='javahierarchy'> + * <li class='c'><a class='doclink' href='../BeanContext.html#ConfigProperties'>BeanContext</a> - Properties associated with handling beans on serializers and parsers. + * <ul> + * <li class='c'><a class='doclink' href='../parser/ParserContext.html#ConfigProperties'>ParserContext</a> - Configurable properties common to all parsers. + * </ul> + * </ul> + * + * * @author James Bognar ([email protected]) */ public class UonParserContext extends ParserContext { /** - * Decode <js>"%xx"</js> sequences. ({@link Boolean}, default=<jk>false</jk> for {@link UonParser}, <jk>true</jk> for {@link UrlEncodingParser}). + * <b>Configuration property:</b> Decode <js>"%xx"</js> sequences. + * <p> + * <ul> + * <li><b>Name:</b> <js>"UonParser.decodeChars"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> for {@link UonParser}, <jk>true</jk> for {@link UrlEncodingParser} + * </ul> * <p> * Specify <jk>true</jk> if URI encoded characters should be decoded, <jk>false</jk> * if they've already been decoded before being passed to this parser. @@ -47,7 +80,15 @@ public class UonParserContext extends ParserContext { public static final String UON_decodeChars = "UonParser.decodeChars"; /** - * Expect input to contain readable whitespace characters from using the {@link UonSerializerContext#UON_useWhitespace} setting ({@link Boolean}, default=<jk>false</jk>). + * <b>Configuration property:</b> Whitespace aware. + * <p> + * <ul> + * <li><b>Name:</b> <js>"UonParser.whitespaceAware"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * </ul> + * <p> + * Expect input to contain readable whitespace characters from using the {@link UonSerializerContext#UON_useWhitespace} setting. */ public static final String UON_whitespaceAware = "UonParser.whitespaceAware"; http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonSerializerContext.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonSerializerContext.java b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonSerializerContext.java index cfcb1c6..94f4700 100644 --- a/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonSerializerContext.java +++ b/juneau-core/src/main/java/org/apache/juneau/urlencoding/UonSerializerContext.java @@ -34,12 +34,51 @@ import org.apache.juneau.serializer.*; * <p> * See {@link ContextFactory} for more information about context properties. * + * + * <h6 class='topic' id='ConfigProperties'>Configurable properties on the URL-Encoding and UON serializers</h6> + * <table class='styled' style='border-collapse: collapse;'> + * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr> + * <tr> + * <td>{@link #UON_simpleMode}</td> + * <td>Use simplified output.</td> + * <td><code>Boolean</code></td> + * <td><jk>false</jk></td> + * </tr> + * <tr> + * <td>{@link #UON_useWhitespace}</td> + * <td>Use whitespace.</td> + * <td><code>Boolean</code></td> + * <td><jk>false</jk></td> + * </tr> + * <tr> + * <td>{@link #UON_encodeChars}</td> + * <td>Encode non-valid URI characters.</td> + * <td><code>Boolean</code></td> + * <td><jk>false</jk> for {@link UonSerializer}<br><jk>true</jk> for {@link UrlEncodingSerializer}</td> + * </tr> + * </table> + * + * <h6 class='topic'>Configurable properties inherited from parent classes</h6> + * <ul class='javahierarchy'> + * <li class='c'><a class='doclink' href='../BeanContext.html#ConfigProperties'>BeanContext</a> - Properties associated with handling beans on serializers and parsers. + * <ul> + * <li class='c'><a class='doclink' href='../serializer/SerializerContext.html#ConfigProperties'>SerializerContext</a> - Configurable properties common to all serializers. + * </ul> + * </ul> + * + * * @author James Bognar ([email protected]) */ public class UonSerializerContext extends SerializerContext { /** - * Use simplified output ({@link Boolean}, default=<jk>false</jk>). + * <b>Configuration property:</b> Use simplified output. + * <p> + * <ul> + * <li><b>Name:</b> <js>"UonSerializer.simpleMode"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * </ul> * <p> * If <jk>true</jk>, type flags will not be prepended to values in most cases. * <p> @@ -92,14 +131,28 @@ public class UonSerializerContext extends SerializerContext { public static final String UON_simpleMode = "UonSerializer.simpleMode"; /** - * Use whitespace in output ({@link Boolean}, default=<jk>false</jk>). + * <b>Configuration property:</b> Use whitespace. + * <p> + * <ul> + * <li><b>Name:</b> <js>"UonSerializer.useWhitespace"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * </ul> * <p> * If <jk>true</jk>, whitespace is added to the output to improve readability. */ public static final String UON_useWhitespace = "UonSerializer.useWhitespace"; /** - * Encode non-valid URI characters to <js>"%xx"</js> constructs. ({@link Boolean}, default=<jk>false</jk> for {@link UonSerializer}, <jk>true</jk> for {@link UrlEncodingSerializer}). + * <b>Configuration property:</b> Encode non-valid URI characters. + * <p> + * <ul> + * <li><b>Name:</b> <js>"UonSerializer.encodeChars"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> for {@link UonSerializer}, <jk>true</jk> for {@link UrlEncodingSerializer} + * </ul> + * <p> + * Encode non-valid URI characters with <js>"%xx"</js> constructs. * <p> * If <jk>true</jk>, non-valid URI characters will be converted to <js>"%xx"</js> sequences. * Set to <jk>false</jk> if parameter value is being passed to some other code that will already http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/urlencoding/package.html ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/urlencoding/package.html b/juneau-core/src/main/java/org/apache/juneau/urlencoding/package.html index 269c7c1..b7cc2ec 100644 --- a/juneau-core/src/main/java/org/apache/juneau/urlencoding/package.html +++ b/juneau-core/src/main/java/org/apache/juneau/urlencoding/package.html @@ -368,7 +368,7 @@ <jk>public</jk> URI <jf>uri</jf>; <jk>public</jk> URI <jf>addressBookUri</jf>; - <ja>@BeanProperty</ja>(transform=CalendarSwap.ISO8601DTZ.<jk>class</jk>) <jk>public</jk> Calendar <jf>birthDate</jf>; + <ja>@BeanProperty</ja>(swap=CalendarSwap.ISO8601DTZ.<jk>class</jk>) <jk>public</jk> Calendar <jf>birthDate</jf>; <jc>// Bean constructor (needed by parser)</jc> http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserContext.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserContext.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserContext.java index 22bf648..017cb70 100644 --- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserContext.java +++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserContext.java @@ -37,26 +37,113 @@ import org.apache.juneau.parser.*; * <p> * See {@link ContextFactory} for more information about context properties. * + * + * <h6 class='topic' id='ConfigProperties'>Configurable properties on the XML parser</h6> + * <table class='styled' style='border-collapse: collapse;'> + * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr> + * <tr> + * <td>{@link #XML_xsiNs}</td> + * <td>XMLSchema-instance namespace URI.</td> + * <td><code>String<code></td> + * <td><js>"http://www.w3.org/2001/XMLSchema-instance"</js></td> + * </tr> + * <tr> + * <td>{@link #XML_trimWhitespace}</td> + * <td>Trim whitespace from text elements.</td> + * <td><code>Boolean<code></td> + * <td><jk>true</jk></td> + * </tr> + * <tr> + * <td>{@link #XML_validating}</td> + * <td>Enable validation.</td> + * <td><code>Boolean<code></td> + * <td><jk>false</jk></td> + * </tr> + * <tr> + * <td>{@link #XML_coalescing}</td> + * <td>Enable text element coalescing.</td> + * <td><code>Boolean<code></td> + * <td><jk>false</jk></td> + * </tr> + * <tr> + * <td>{@link #XML_replaceEntityReferences}</td> + * <td>Replace entity references.</td> + * <td><code>Boolean<code></td> + * <td><jk>true</jk></td> + * </tr> + * <tr> + * <td>{@link #XML_reporter}</td> + * <td>XML reporter.</td> + * <td>{@link XMLReporter}</td> + * <td><jk>null</jk></td> + * </tr> + * <tr> + * <td>{@link #XML_resolver}</td> + * <td>XML resolver.</td> + * <td>{@link XMLResolver}</td> + * <td><jk>null</jk></td> + * </tr> + * <tr> + * <td>{@link #XML_eventAllocator}</td> + * <td>XML event allocator.</td> + * <td>{@link XMLEventAllocator}</td> + * <td><jk>null</jk></td> + * </tr> + * <tr> + * <td>{@link #XML_preserveRootElement}</td> + * <td>Preserve root element during generalized parsing.</td> + * <td><code>Boolean<code></td> + * <td><jk>false</jk></td> + * </tr> + * </table> + * + * <h6 class='topic'>Configurable properties inherited from parent classes</h6> + * <ul class='javahierarchy'> + * <li class='c'><a class='doclink' href='../BeanContext.html#ConfigProperties'>BeanContext</a> - Properties associated with handling beans on serializers and parsers. + * <ul> + * <li class='c'><a class='doclink' href='../parser/ParserContext.html#ConfigProperties'>ParserContext</a> - Configurable properties common to all parsers. + * </ul> + * </ul> + * + * * @author James Bognar ([email protected]) */ public final class XmlParserContext extends ParserContext { /** - * XMLSchema-instance namespace URI ({@link String}, default=<js>"http://www.w3.org/2001/XMLSchema-instance"</js>). + * <b>Configuration property:</b> XMLSchema-instance namespace URI. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlParser.xsiNs"</js> + * <li><b>Data type:</b> <code>String</code> + * <li><b>Default:</b> <js>"http://www.w3.org/2001/XMLSchema-instance"</js> + * </ul> * <p> * The XMLSchema namespace. */ public static final String XML_xsiNs = "XmlParser.xsiNs"; /** - * Trim whitespace from text elements ({@link Boolean}, default=<jk>true</jk>). + * <b>Configuration property:</b> Trim whitespace from text elements. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlParser.trimWhitespace"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>true</jk> + * </ul> * <p> * If <jk>true</jk>, whitespace in text elements will be automatically trimmed. */ public static final String XML_trimWhitespace = "XmlParser.trimWhitespace"; /** - * Set validating mode ({@link Boolean}, default=<jk>false</jk>). + * <b>Configuration property:</b> Enable validation. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlParser.validating"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * </ul> * <p> * If <jk>true</jk>, XML document will be validated. * See {@link XMLInputFactory#IS_VALIDATING} for more info. @@ -64,7 +151,13 @@ public final class XmlParserContext extends ParserContext { public static final String XML_validating = "XmlParser.validating"; /** - * Set coalescing mode ({@link Boolean}, default=<jk>false</jk>). + * <b>Configuration property:</b> Enable text element coalescing. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlParser.coalescing"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * </ul> * <p> * If <jk>true</jk>, XML text elements will be coalesced. * See {@link XMLInputFactory#IS_COALESCING} for more info. @@ -72,7 +165,13 @@ public final class XmlParserContext extends ParserContext { public static final String XML_coalescing = "XmlParser.coalescing"; /** - * Replace entity references ({@link Boolean}, default=<jk>true</jk>). + * <b>Configuration property:</b> Replace entity references. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlParser.replaceEntityReferences"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>true</jk> + * </ul> * <p> * If <jk>true</jk>, entity references will be replace during parsing. * See {@link XMLInputFactory#IS_REPLACING_ENTITY_REFERENCES} for more info. @@ -80,7 +179,13 @@ public final class XmlParserContext extends ParserContext { public static final String XML_replaceEntityReferences = "XmlParser.replaceEntityReferences"; /** - * XML reporter ({@link XMLReporter}, default=<jk>null</jk>). + * <b>Configuration property:</b> XML reporter. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlParser.reporter"</js> + * <li><b>Data type:</b> {@link XMLReporter} + * <li><b>Default:</b> <jk>null</jk> + * </ul> * <p> * Associates an {@link XMLReporter} with this parser. * <p> @@ -89,21 +194,39 @@ public final class XmlParserContext extends ParserContext { public static final String XML_reporter = "XmlParser.reporter"; /** - * XML resolver ({@link XMLResolver}, default=<jk>null</jk>). + * <b>Configuration property:</b> XML resolver. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlParser.resolver"</js> + * <li><b>Data type:</b> {@link XMLResolver} + * <li><b>Default:</b> <jk>null</jk> + * </ul> * <p> * Associates an {@link XMLResolver} with this parser. */ public static final String XML_resolver = "XmlParser.resolver"; /** - * XML event allocator. ({@link XMLEventAllocator}, default=<jk>false</jk>). + * <b>Configuration property:</b> XML event allocator. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlParser.eventAllocator"</js> + * <li><b>Data type:</b> {@link XMLEventAllocator} + * <li><b>Default:</b> <jk>null</jk> + * </ul> * <p> * Associates an {@link XMLEventAllocator} with this parser. */ public static final String XML_eventAllocator = "XmlParser.eventAllocator"; /** - * Preserve root element during generalized parsing ({@link Boolean}, default=<jk>false</jk>). + * <b>Configuration property:</b> Preserve root element during generalized parsing. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlParser.preserveRootElement"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * </ul> * <p> * If <jk>true</jk>, when parsing into a generic {@link ObjectMap}, the map will * contain a single entry whose key is the root element name. http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java index b3e6b83..ff4f40b 100644 --- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java +++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java @@ -61,24 +61,44 @@ import org.apache.juneau.xml.annotation.*; * <js>'fico score'</js>: <js>' > 640'</js> * } * <p> - * ...maps to the following XML... + * ...maps to the following XML using the default serializer... * <p class='bcode'> * <xt><object></xt> - * <xt><name</xt> <xa>type</xa>=<xs>'string'</xs><xt>></xt>John Smith<xt></name></xt> - * <xt><address</xt> <xa>type</xa>=<xs>'object'</xs><xt>></xt> - * <xt><streetAddress</xt> <xa>type</xa>=<xs>'string'</xs><xt>></xt>21 2nd Street<xt></streetAddress></xt> - * <xt><city</xt> <xa>type</xa>=<xs>'string'</xs><xt>></xt>New York<xt></city></xt> - * <xt><state</xt> <xa>type</xa>=<xs>'string'</xs><xt>></xt>NY<xt></state></xt> - * <xt><postalCode</xt> <xa>type</xa>=<xs>'number'</xs><xt>></xt>10021<xt></postalCode></xt> + * <xt><name></xt>John Smith<xt></name></xt> + * <xt><address></xt> + * <xt><streetAddress></xt>21 2nd Street<xt></streetAddress></xt> + * <xt><city></xt>New York<xt></city></xt> + * <xt><state></xt>NY<xt></state></xt> + * <xt><postalCode></xt>10021<xt></postalCode></xt> * <xt></address></xt> - * <xt><phoneNumbers</xt> <xa>type</xa>=<xs>'array'</xs><xt>></xt> + * <xt><phoneNumbers></xt> * <xt><string></xt>212 555-1111<xt></string></xt> * <xt><string></xt>212 555-2222<xt></string></xt> * <xt></phoneNumbers></xt> - * <xt><additionalInfo</xt> <xa>type</xa>=<xs>'null'</xs><xt>></additionalInfo></xt> - * <xt><remote</xt> <xa>type</xa>=<xs>'boolean'</xs><xt>></xt>false<xt></remote></xt> - * <xt><height</xt> <xa>type</xa>=<xs>'number'</xs><xt>></xt>62.4<xt></height></xt> - * <xt><fico_x0020_score</xt> <xa>type</xa>=<xs>'string'</xs><xt>></xt> &gt; 640<xt></fico_x0020_score></xt> + * <xt><additionalInfo</xt> <xa>_type</xa>=<xs>'null'</xs><xt>></additionalInfo></xt> + * <xt><remote></xt>false<xt></remote></xt> + * <xt><height></xt>62.4<xt></height></xt> + * <xt><fico_x0020_score></xt> &gt; 640<xt></fico_x0020_score></xt> + * <xt></object></xt> + * <p> + * An additional "add-json-properties" mode is also provided to prevent loss of JSON data types... + * <p class='bcode'> + * <xt><object></xt> + * <xt><name</xt> <xa>_type</xa>=<xs>'string'</xs><xt>></xt>John Smith<xt></name></xt> + * <xt><address</xt> <xa>_type</xa>=<xs>'object'</xs><xt>></xt> + * <xt><streetAddress</xt> <xa>_type</xa>=<xs>'string'</xs><xt>></xt>21 2nd Street<xt></streetAddress></xt> + * <xt><city</xt> <xa>_type</xa>=<xs>'string'</xs><xt>></xt>New York<xt></city></xt> + * <xt><state</xt> <xa>_type</xa>=<xs>'string'</xs><xt>></xt>NY<xt></state></xt> + * <xt><postalCode</xt> <xa>_type</xa>=<xs>'number'</xs><xt>></xt>10021<xt></postalCode></xt> + * <xt></address></xt> + * <xt><phoneNumbers</xt> <xa>_type</xa>=<xs>'array'</xs><xt>></xt> + * <xt><string></xt>212 555-1111<xt></string></xt> + * <xt><string></xt>212 555-2222<xt></string></xt> + * <xt></phoneNumbers></xt> + * <xt><additionalInfo</xt> <xa>_type</xa>=<xs>'null'</xs><xt>></additionalInfo></xt> + * <xt><remote</xt> <xa>_type</xa>=<xs>'boolean'</xs><xt>></xt>false<xt></remote></xt> + * <xt><height</xt> <xa>_type</xa>=<xs>'number'</xs><xt>></xt>62.4<xt></height></xt> + * <xt><fico_x0020_score</xt> <xa>_type</xa>=<xs>'string'</xs><xt>></xt> &gt; 640<xt></fico_x0020_score></xt> * <xt></object></xt> * <p> * This serializer provides several serialization options. Typically, one of the predefined <jsf>DEFAULT</jsf> serializers will be sufficient. http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d45e1351/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerContext.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerContext.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerContext.java index c1fba2e..ad2001c 100644 --- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerContext.java +++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerContext.java @@ -34,19 +34,100 @@ import org.apache.juneau.serializer.*; * <p> * See {@link ContextFactory} for more information about context properties. * + * + * <h6 class='topic' id='ConfigProperties'>Configurable properties on the XML serializer</h6> + * <table class='styled' style='border-collapse: collapse;'> + * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th></tr> + * <tr> + * <td>{@link #XML_addJsonTypeAttrs}</td> + * <td>Add JSON type attributes to output.</td> + * <td><code>Boolean</code></td> + * <td><jk>false</jk></td> + * </tr> + * <tr> + * <td>{@link #XML_addJsonStringTypeAttrs}</td> + * <td>Add JSON type attributes for strings to output.</td> + * <td><code>Boolean</code></td> + * <td><jk>false</jk></td> + * </tr> + * <tr> + * <td>{@link #XML_enableNamespaces}</td> + * <td>Enable support for XML namespaces.</td> + * <td><code>Boolean</code></td> + * <td><jk>true</jk></td> + * </tr> + * <tr> + * <td>{@link #XML_autoDetectNamespaces}</td> + * <td>Auto-detect namespace usage.</td> + * <td><code>Boolean</code></td> + * <td><jk>true</jk></td> + * </tr> + * <tr> + * <td>{@link #XML_addNamespaceUrisToRoot}</td> + * <td>Add namespace URLs to the root element.</td> + * <td><code>Boolean</code></td> + * <td><jk>true</jk></td> + * </tr> + * <tr> + * <td>{@link #XML_defaultNamespaceUri}</td> + * <td>Default namespace URI.</td> + * <td><code>String</code></td> + * <td><jk>null</jk></td> + * </tr> + * <tr> + * <td>{@link #XML_xsNamespace}</td> + * <td>XMLSchema namespace.</td> + * <td>{@link Namespace}</td> + * <td><code>{name:<js>'xs'</js>,uri:<js>'http://www.w3.org/2001/XMLSchema'</js>}</code></td> + * </tr> + * <tr> + * <td>{@link #XML_xsiNamespace}</td> + * <td>XMLSchema-Instance namespace.</td> + * <td>{@link Namespace}</td> + * <td><code>{name:<js>'xsi'</js>,uri:<js>'http://www.w3.org/2001/XMLSchema-instance'</js>}</code></td> + * </tr> + * <tr> + * <td>{@link #XML_namespaces}</td> + * <td>Default namespaces.</td> + * <td><code>Set<{@link Namespace}></code></td> + * <td>empty set</td> + * </tr> + * </table> + * + * <h6 class='topic'>Configurable properties inherited from parent classes</h6> + * <ul class='javahierarchy'> + * <li class='c'><a class='doclink' href='../BeanContext.html#ConfigProperties'>BeanContext</a> - Properties associated with handling beans on serializers and parsers. + * <ul> + * <li class='c'><a class='doclink' href='../serializer/SerializerContext.html#ConfigProperties'>SerializerContext</a> - Configurable properties common to all serializers. + * </ul> + * </ul> +* + * * @author James Bognar ([email protected]) */ public class XmlSerializerContext extends SerializerContext { /** - * Add JSON type attributes to output ({@link Boolean}, default=<jk>false</jk>). + * <b>Configuration property:</b> Add JSON type attributes to output. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlSerializer.addJsonTypeAttrs"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * </ul> * <p> * If <js>true</jk>, {@code type} attributes will be added to elements in the XML for number/boolean/null nodes. */ public static final String XML_addJsonTypeAttrs = "XmlSerializer.addJsonTypeAttrs"; /** - * Add JSON type attributes for strings to output ({@link Boolean}, default=<jk>false</jk>). + * <b>Configuration property:</b> Add JSON type attributes for strings to output. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlSerializer.addJsonStringTypeAttrs"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * </ul> * <p> * If <jk>true</jk>, {@code type} attributes will be added to elements in the XML for string nodes. * <p> @@ -58,14 +139,26 @@ public class XmlSerializerContext extends SerializerContext { public static final String XML_addJsonStringTypeAttrs = "XmlSerializer.addJsonStringTypeAttrs"; /** - * Enable support for XML namespaces ({@link Boolean}, default=<jk>true</jk>). + * <b>Configuration property:</b> Enable support for XML namespaces. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlSerializer.enableNamespaces"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>true</jk> + * </ul> * <p> * If not enabled, XML output will not contain any namespaces regardless of any other settings. */ public static final String XML_enableNamespaces = "XmlSerializer.enableNamespaces"; /** - * Auto-detect namespace usage ({@link Boolean}, default=<jk>true</jk>). + * <b>Configuration property:</b> Auto-detect namespace usage. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlSerializer.autoDetectNamespaces"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>true</jk> + * </ul> * <p> * Detect namespace usage before serialization. * <p> @@ -87,7 +180,13 @@ public class XmlSerializerContext extends SerializerContext { public static final String XML_autoDetectNamespaces = "XmlSerializer.autoDetectNamespaces"; /** - * Add namespace URLs to the root element ({@link Boolean}, default=<jk>true</jk>). + * <b>Configuration property:</b> Add namespace URLs to the root element. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlSerializer.addNamespaceUrisToRoot"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>true</jk> + * </ul> * <p> * Use this setting to add {@code xmlns:x} attributes to the root * element for the default and all mapped namespaces. @@ -97,14 +196,26 @@ public class XmlSerializerContext extends SerializerContext { public static final String XML_addNamespaceUrisToRoot = "XmlSerializer.addNamespaceUrisToRoot"; /** - * Default namespace URI ({@link String}, default=<jk>null</jk>). + * <b>Configuration property:</b> Default namespace URI. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlSerializer.defaultNamespaceUri"</js> + * <li><b>Data type:</b> <code>String</code> + * <li><b>Default:</b> <jk>null</jk> + * </ul> * <p> * Specifies the default namespace URI for this document. */ public static final String XML_defaultNamespaceUri = "XmlSerializer.defaultNamespaceUri"; /** - * XMLSchema namespace ({@link Namespace}, default=<code>{name:<js>'xs'</js>,uri:<js>'http://www.w3.org/2001/XMLSchema'</js>}</code>). + * <b>Configuration property:</b> XMLSchema namespace. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlSerializer.xsNamespace"</js> + * <li><b>Data type:</b> {@link Namespace} + * <li><b>Default:</b> <code>{name:<js>'xs'</js>,uri:<js>'http://www.w3.org/2001/XMLSchema'</js>}</code> + * </ul> * <p> * Specifies the namespace for the <code>XMLSchema</code> namespace, used by the schema generated * by the {@link XmlSchemaSerializer} class. @@ -112,14 +223,26 @@ public class XmlSerializerContext extends SerializerContext { public static final String XML_xsNamespace = "XmlSerializer.xsNamespace"; /** - * XMLSchema-Instance namespace ({@link Namespace}, default=<code>{name:<js>'xsi'</js>,uri:<js>'http://www.w3.org/2001/XMLSchema-instance'</js>}</code>). + * <b>Configuration property:</b> XMLSchema-Instance namespace. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlSerializer.xsiNamespace"</js> + * <li><b>Data type:</b> {@link Namespace} + * <li><b>Default:</b> <code>{name:<js>'xsi'</js>,uri:<js>'http://www.w3.org/2001/XMLSchema-instance'</js>}</code> + * </ul> * <p> * Specifies the namespace of the <code>XMLSchema-instance</code> namespace used for<code>nil=<jk>true</jk></code> attributes. */ public static final String XML_xsiNamespace = "XmlSerializer.xsiNamespace"; /** - * Default namespaces (<code>Set<Namespace></code>, default=empty set). + * <b>Configuration property:</b> Default namespaces. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlSerializer.namespaces"</js> + * <li><b>Data type:</b> <code>Set<{@link Namespace}></code> + * <li><b>Default:</b> empty set + * </ul> * <p> * The default list of namespaces associated with this serializer. */
