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/20 01:49:50 UTC
[5/7] incubator-juneau git commit: Move configuration properties to
serializer and parser classes.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d22f1b26/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializer.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializer.java
index 63cfcf2..d99be25 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializer.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializer.java
@@ -29,21 +29,478 @@ import org.apache.juneau.serializer.*;
* Same as {@link HtmlSerializer}, except wraps the response in <code><xt><html></code>,
* <code><xt><head></code>, and <code><xt><body></code> tags so that it can be rendered in a browser.
*
- * <h5 class='section'>Configurable properties:</h5>
+ * <p>
+ * Configurable properties are typically specified via <ja>@RestResource.properties()</ja> and <ja>@RestMethod.properties()</ja>
+ * annotations, although they can also be set programmatically via the <code>RestResponse.setProperty()</code> method.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode'>
+ * <ja>@RestResource</ja>(
+ * messages=<js>"nls/AddressBookResource"</js>,
+ * properties={
+ * <ja>@Property</ja>(name=HtmlDocSerializer.<jsf>HTMLDOC_title</jsf>, value=<js>"$L{title}"</js>),
+ * <ja>@Property</ja>(name=HtmlDocSerializer.<jsf>HTMLDOC_description</jsf>, value=<js>"$L{description}"</js>),
+ * <ja>@Property</ja>(name=HtmlDocSerializer.<jsf>HTMLDOC_navlinks</jsf>, value=<js>"{options:'?method=OPTIONS',doc:'doc'}"</js>)
+ * }
+ * )
+ * <jk>public class</jk> AddressBookResource <jk>extends</jk> RestServletJenaDefault {
+ * </p>
+ *
+ * <p>
+ * Note that shortcut annotations are also provided for these particular settings:
+ * <p class='bcode'>
+ * <ja>@RestResource</ja>(
+ * messages=<js>"nls/AddressBookResource"</js>,
+ * htmldoc=<ja>@HtmlDoc</ja>(
+ * title=<js>"$L{title}"</js>,
+ * description=<js>"$L{description}"</js>,
+ * navlinks={
+ * <js>"options: ?method=OPTIONS"</js>,
+ * <js>"doc: doc"</js>
+ * }
+ * )
+ * )
+ * </p>
*
- * This class has the following properties associated with it:
- * <ul>
- * <li>{@link HtmlDocSerializerContext}
- * <li>{@link BeanContext}
- * </ul>
+ * <p>
+ * The <code>$L{...}</code> variable represent localized strings pulled from the resource bundle identified by the
+ * <code>messages</code> annotation.
+ * These variables are replaced at runtime based on the HTTP request locale.
+ * Several built-in runtime variable types are defined, and the API can be extended to include user-defined variables.
*/
@SuppressWarnings("hiding")
public class HtmlDocSerializer extends HtmlStrippedDocSerializer {
+ //-------------------------------------------------------------------------------------------------------------------
+ // Configurable properties
+ //-------------------------------------------------------------------------------------------------------------------
+
+ private static final String PREFIX = "HtmlDocSerializer.";
+
+ /**
+ * <b>Configuration property:</b> Header section contents.
+ *
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlDocSerializer.header"</js>
+ * <li><b>Data type:</b> <code>String[]</code>
+ * <li><b>Default:</b> <jk>null</jk>
+ * <li><b>Session-overridable:</b> <jk>true</jk>
+ * </ul>
+ *
+ * <p>
+ * Allows you to override the contents of the header section on the HTML page.
+ * The header section normally contains the title and description at the top of the page.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode'>
+ * <ja>@RestResource</ja>(
+ * htmldoc=<ja>@HtmlDoc</ja>(
+ * header={
+ * <js>"<h1>My own header</h1>"</js>
+ * }
+ * )
+ * )
+ * </p>
+ */
+ public static final String HTMLDOC_header = PREFIX + "header.list";
+
+ /**
+ * <b>Configuration property:</b> Page navigation links.
+ *
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlDocSerializer.navlinks.list"</js>
+ * <li><b>Data type:</b> <code>String[]</code>
+ * <li><b>Default:</b> empty array
+ * <li><b>Session-overridable:</b> <jk>true</jk>
+ * </ul>
+ *
+ * <p>
+ * Adds a list of hyperlinks immediately under the title and description but above the content of the page.
+ *
+ * <p>
+ * This can be used to provide convenient hyperlinks when viewing the REST interface from a browser.
+ *
+ * <p>
+ * The value is an array of strings with two possible values:
+ * <ul>
+ * <li>A key-value pair representing a hyperlink label and href:
+ * <br><js>"google: http://google.com"</js>
+ * <li>Arbitrary HTML.
+ * </ul>
+ *
+ * <p>
+ * Relative URLs are considered relative to the servlet path.
+ * For example, if the servlet path is <js>"http://localhost/myContext/myServlet"</js>, and the
+ * URL is <js>"foo"</js>, the link becomes <js>"http://localhost/myContext/myServlet/foo"</js>.
+ * Absolute (<js>"/myOtherContext/foo"</js>) and fully-qualified (<js>"http://localhost2/foo"</js>) URLs
+ * can also be used in addition to various other protocols specified by {@link UriResolver} such as
+ * <js>"servlet:/..."</js>.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p>
+ * The <code>AddressBookResource</code> sample class uses this property...
+ * <p class='bcode'>
+ * <ja>@RestResource</ja>(
+ * properties={
+ * <ja>@Property</ja>(name=HtmlDocSerializerContext.<jsf>HTMLDOC_navlinks</jsf>,
+ * value=<js>"['options: ?method=OPTIONS', 'doc: doc']"</js>)
+ * }
+ * )
+ * <jk>public class</jk> AddressBookResource <jk>extends</jk> RestServletJenaDefault {
+ * </p>
+ *
+ * <p>
+ * ...to produce this list of links on the HTML page...
+ * <img class='bordered' src='doc-files/HTML_LINKS.png'>
+ *
+ * <p>
+ * A shortcut on <ja>@RestResource</ja> is also provided for this setting:
+ * <p class='bcode'>
+ * <ja>@RestResource</ja>(
+ * htmldoc=@HtmlDoc(
+ * navlinks={
+ * <js>"options: ?method=OPTIONS"</js>,
+ * <js>"doc: doc"</js>
+ * }
+ * )
+ * )
+ * <jk>public class</jk> AddressBookResource <jk>extends</jk> RestServletJenaDefault {
+ * </p>
+ */
+ public static final String HTMLDOC_navlinks = PREFIX + "navlinks.list";
+
+ /**
+ * <b>Configuration property:</b> Add to the {@link #HTMLDOC_navlinks} property.
+ */
+ public static final String HTMLDOC_navlinks_add = PREFIX + "navlinks.list.add";
+
+ /**
+ * <b>Configuration property:</b> Nav section contents.
+ *
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlDocSerializer.nav"</js>
+ * <li><b>Data type:</b> <code>String[]</code>
+ * <li><b>Default:</b> <jk>null</jk>
+ * <li><b>Session-overridable:</b> <jk>true</jk>
+ * </ul>
+ *
+ * <p>
+ * Allows you to override the contents of the nav section on the HTML page.
+ * The nav section normally contains the page links at the top of the page.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode'>
+ * <ja>@RestResource</ja>(
+ * htmldoc=<ja>@HtmlDoc</ja>(
+ * nav={
+ * <js>"<p class='special-navigation'>This is my special navigation content</p>"</js>
+ * }
+ * )
+ * )
+ * </p>
+ *
+ * <p>
+ * When this property is specified, the {@link #HTMLDOC_navlinks} property is ignored.
+ */
+ public static final String HTMLDOC_nav = PREFIX + "nav.list";
+
+ /**
+ * <b>Configuration property:</b> Aside section contents.
+ *
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlDocSerializer.aside"</js>
+ * <li><b>Data type:</b> <code>String[]</code>
+ * <li><b>Default:</b> <jk>null</jk>
+ * <li><b>Session-overridable:</b> <jk>true</jk>
+ * </ul>
+ *
+ * <p>
+ * Allows you to specify the contents of the aside section on the HTML page.
+ * The aside section floats on the right of the page for providing content supporting the serialized content of
+ * the page.
+ *
+ * <p>
+ * By default, the aside section is empty.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode'>
+ * <ja>@RestResource</ja>(
+ * htmldoc=<ja>@HtmlDoc</ja>(
+ * aside={
+ * <js>"<ul>"</js>,
+ * <js>" <li>Item 1"</js>,
+ * <js>" <li>Item 2"</js>,
+ * <js>" <li>Item 3"</js>,
+ * <js>"</ul>"</js>
+ * }
+ * )
+ * )
+ * </p>
+ */
+ public static final String HTMLDOC_aside = PREFIX + "aside.list";
+
+ /**
+ * <b>Configuration property:</b> Footer section contents.
+ *
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlDocSerializer.footer"</js>
+ * <li><b>Data type:</b> <code>String[]</code>
+ * <li><b>Default:</b> <jk>null</jk>
+ * <li><b>Session-overridable:</b> <jk>true</jk>
+ * </ul>
+ *
+ * <p>
+ * Allows you to specify the contents of the footer section on the HTML page.
+ *
+ * <p>
+ * By default, the footer section is empty.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode'>
+ * <ja>@RestResource</ja>(
+ * htmldoc=<ja>@HtmlDoc</ja>(
+ * footer={
+ * <js>"<b>This interface is great!</b>"</js>
+ * }
+ * )
+ * )
+ * </p>
+ */
+ public static final String HTMLDOC_footer = PREFIX + "footer.list";
+
+ /**
+ * <b>Configuration property:</b> No-results message.
+ *
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlDocSerializer.noResultsMessage"</js>
+ * <li><b>Data type:</b> <code>String</code>
+ * <li><b>Default:</b> <js>"<p>no results</p>"</js>
+ * <li><b>Session-overridable:</b> <jk>true</jk>
+ * </ul>
+ *
+ * <p>
+ * Allows you to specify the string message used when trying to serialize an empty array or empty list.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode'>
+ * <ja>@RestResource</ja>(
+ * htmldoc=<ja>@HtmlDoc</ja>(
+ * noResultsMessage=<js>"<b>This interface is great!</b>"</js>
+ * )
+ * )
+ * </p>
+ *
+ * <p>
+ * A value of <js>"NONE"</js> can be used to represent no value to differentiate it from an empty string.
+ */
+ public static final String HTMLDOC_noResultsMessage = PREFIX + "noResultsMessage";
+
+ /**
+ * <b>Configuration property:</b> Prevent word wrap on page.
+ *
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlDocSerializer.nowrap"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * <li><b>Session-overridable:</b> <jk>true</jk>
+ * </ul>
+ *
+ * <p>
+ * Adds <js>"* {white-space:nowrap}"</js> to the CSS instructions on the page to prevent word wrapping.
+ */
+ public static final String HTMLDOC_nowrap = PREFIX + "nowrap";
+
+ /**
+ * <b>Configuration property:</b> Stylesheet import URLs.
+ *
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlDocSerializer.stylesheet"</js>
+ * <li><b>Data type:</b> <code>String[]</code>
+ * <li><b>Default:</b> empty array
+ * <li><b>Session-overridable:</b> <jk>true</jk>
+ * </ul>
+ *
+ * <p>
+ * Adds a link to the specified stylesheet URL.
+ *
+ * <p>
+ * Note that this stylesheet is controlled by the <code><ja>@RestResource</ja>.stylesheet()</code> annotation.
+ */
+ public static final String HTMLDOC_stylesheet = PREFIX + "stylesheet.list";
+
+ /**
+ * <b>Configuration property:</b> Add to the {@link #HTMLDOC_stylesheet} property.
+ */
+ public static final String HTMLDOC_stylesheet_add = PREFIX + "stylesheet.list.add";
+
+ /**
+ * <b>Configuration property:</b> CSS style code.
+ *
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlDocSerializer.style.list"</js>
+ * <li><b>Data type:</b> <code>String[]</code>
+ * <li><b>Default:</b> empty array
+ * <li><b>Session-overridable:</b> <jk>true</jk>
+ * </ul>
+ *
+ * <p>
+ * Adds the specified CSS instructions to the HTML page.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode'>
+ * <ja>@RestResource</ja>(
+ * properties={
+ * <ja>@Property</ja>(name=HtmlDocSerializerContext.<jsf>HTMLDOC_style</jsf>,
+ * value=<js>"h3 { color: red; }\nh5 { font-weight: bold; }"</js>)
+ * }
+ * )
+ * </p>
+ *
+ * <p>
+ * A shortcut on <ja>@RestResource</ja> is also provided for this setting:
+ * <p class='bcode'>
+ * <ja>@RestResource</ja>(
+ * htmldoc=@HtmlDoc(
+ * style={
+ * <js>"h3 { color: red; }"</js>,
+ * <js>"h5 { font-weight: bold; }"</js>
+ * }
+ * )
+ * )
+ * </p>
+ */
+ public static final String HTMLDOC_style = PREFIX + "style.list";
+
+ /**
+ * <b>Configuration property:</b> Add to the {@link #HTMLDOC_style} property.
+ */
+ public static final String HTMLDOC_style_add = PREFIX + "style.list.add";
+
+ /**
+ * <b>Configuration property:</b> Javascript code.
+ *
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlDocSerializer.script.list"</js>
+ * <li><b>Data type:</b> <code>String[]</code>
+ * <li><b>Default:</b> empty array
+ * <li><b>Session-overridable:</b> <jk>true</jk>
+ * </ul>
+ *
+ * <p>
+ * Adds the specified Javascript code to the HTML page.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode'>
+ * <ja>@RestResource</ja>(
+ * properties={
+ * <ja>@Property</ja>(name=HtmlDocSerializerContext.<jsf>HTMLDOC_script</jsf>,
+ * value=<js>"alert('hello!');"</js>)
+ * }
+ * )
+ * </p>
+ *
+ * <p>
+ * A shortcut on <ja>@RestResource</ja> is also provided for this setting:
+ * <p class='bcode'>
+ * <ja>@RestResource</ja>(
+ * htmldoc=@HtmlDoc(
+ * script={
+ * <js>"alert('hello!');"</js>
+ * }
+ * )
+ * )
+ * </p>
+ */
+ public static final String HTMLDOC_script = PREFIX + "script.list";
+
+ /**
+ * <b>Configuration property:</b> Add to the {@link #HTMLDOC_script} property.
+ */
+ public static final String HTMLDOC_script_add = PREFIX + "script.list.add";
+
+ /**
+ * <b>Configuration property:</b> Additional head section content.
+ *
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlDocSerializer.head.list"</js>
+ * <li><b>Data type:</b> <code>String[]</code>
+ * <li><b>Default:</b> empty array
+ * <li><b>Session-overridable:</b> <jk>true</jk>
+ * </ul>
+ *
+ * <p>
+ * Adds the specified HTML content to the head section of the page.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode'>
+ * <ja>@RestResource</ja>(
+ * properties={
+ * <ja>@Property</ja>(name=HtmlDocSerializerContext.<jsf>HTMLDOC_links</jsf>,
+ * value=<js>"['<link rel=\"icon\" href=\"htdocs/mypageicon.ico\">']"</js>)
+ * }
+ * )
+ * </p>
+ *
+ * <p>
+ * A shortcut on <ja>@RestResource</ja> is also provided for this setting:
+ * <p class='bcode'>
+ * <ja>@RestResource</ja>(
+ * htmldoc=@HtmlDoc(
+ * head={
+ * <js>"<link rel='icon' href='$U{servlet:/htdocs/mypageicon.ico}'>"</js>
+ * }
+ * )
+ * )
+ * </p>
+ */
+ public static final String HTMLDOC_head = PREFIX + "head.list";
+
+ /**
+ * <b>Configuration property:</b> Add to the {@link #HTMLDOC_head} property.
+ */
+ public static final String HTMLDOC_links_add = PREFIX + "head.list.add";
+
+ /**
+ * <b>Configuration property:</b> HTML document template.
+ *
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlDocSerializer.template"</js>
+ * <li><b>Data type:</b> <code>Class<? <jk>extends</jk> HtmlDocTemplate></code> or {@link HtmlDocTemplate}
+ * <li><b>Default:</b> <code>HtmlDocTemplateBasic.<jk>class</jk></code>
+ * <li><b>Session-overridable:</b> <jk>true</jk>
+ * </ul>
+ *
+ * <p>
+ * Specifies the template to use for serializing the page.
+ *
+ * <p>
+ * By default, the {@link HtmlDocTemplateBasic} class is used to construct the contents of the HTML page, but
+ * can be overridden with your own custom implementation class.
+ *
+ * <h5 class='section'>Example:</h5>
+ * <p class='bcode'>
+ * <ja>@RestResource</ja>(
+ * htmldoc=@HtmlDoc(
+ * template=MySpecialDocTemplate.<jk>class</jk>
+ * )
+ * )
+ * </p>
+ */
+ public static final String HTMLDOC_template = PREFIX + "template";
+
+
+ //-------------------------------------------------------------------------------------------------------------------
+ // Predefined instances
+ //-------------------------------------------------------------------------------------------------------------------
+
/** Default serializer, all default settings. */
public static final HtmlDocSerializer DEFAULT = new HtmlDocSerializer(PropertyStore.create());
+ //-------------------------------------------------------------------------------------------------------------------
+ // Instance
+ //-------------------------------------------------------------------------------------------------------------------
+
final HtmlDocSerializerContext ctx;
/**
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d22f1b26/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializerContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializerContext.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializerContext.java
index ef2b964..4b6fb1e 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializerContext.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializerContext.java
@@ -12,486 +12,15 @@
// ***************************************************************************************************************************
package org.apache.juneau.html;
+import static org.apache.juneau.html.HtmlDocSerializer.*;
+
import org.apache.juneau.*;
/**
- * Properties associated with the {@link HtmlDocSerializer} class.
- *
- * <p>
- * These are typically specified via <ja>@RestResource.properties()</ja> and <ja>@RestMethod.properties()</ja>
- * annotations, although they can also be set programmatically via the <code>RestResponse.setProperty()</code> method.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode'>
- * <ja>@RestResource</ja>(
- * messages=<js>"nls/AddressBookResource"</js>,
- * properties={
- * <ja>@Property</ja>(name=HtmlDocSerializerContext.<jsf>HTMLDOC_title</jsf>, value=<js>"$L{title}"</js>),
- * <ja>@Property</ja>(name=HtmlDocSerializerContext.<jsf>HTMLDOC_description</jsf>, value=<js>"$L{description}"</js>),
- * <ja>@Property</ja>(name=HtmlDocSerializerContext.<jsf>HTMLDOC_navlinks</jsf>, value=<js>"{options:'?method=OPTIONS',doc:'doc'}"</js>)
- * }
- * )
- * <jk>public class</jk> AddressBookResource <jk>extends</jk> RestServletJenaDefault {
- * </p>
- *
- * <p>
- * Note that shortcut annotations are also provided for these particular settings:
- * <p class='bcode'>
- * <ja>@RestResource</ja>(
- * messages=<js>"nls/AddressBookResource"</js>,
- * htmldoc=<ja>@HtmlDoc</ja>(
- * title=<js>"$L{title}"</js>,
- * description=<js>"$L{description}"</js>,
- * navlinks={
- * <js>"options: ?method=OPTIONS"</js>,
- * <js>"doc: doc"</js>
- * }
- * )
- * )
- * </p>
- *
- * <p>
- * The <code>$L{...}</code> variable represent localized strings pulled from the resource bundle identified by the
- * <code>messages</code> annotation.
- * These variables are replaced at runtime based on the HTTP request locale.
- * Several built-in runtime variable types are defined, and the API can be extended to include user-defined variables.
- *
- * <h6 class='topic'>Inherited configurable properties</h6>
- * <ul class='doctree'>
- * <li class='jc'>
- * <a class="doclink" href="../BeanContext.html#ConfigProperties">BeanContext</a>
- * - Properties associated with handling beans on serializers and parsers.
- * <ul>
- * <li class='jc'>
- * <a class="doclink" href="../serializer/SerializerContext.html#ConfigProperties">SerializerContext</a>
- * - Configurable properties common to all serializers.
- * <ul>
- * <li class='jc'>
- * <a class="doclink" href="../html/HtmlSerializerContext.html#ConfigProperties">HtmlSerializerContext</a>
- * - Configurable properties on the HTML serializer.
- * </ul>
- * </li>
- * </ul>
- * </li>
- * </ul>
+ * Contains a snapshot-in-time read-only copy of the settings on the {@link HtmlDocSerializer} class.
*/
public final class HtmlDocSerializerContext extends HtmlSerializerContext {
- @SuppressWarnings("hiding")
- static final String PREFIX = "HtmlDocSerializer.";
-
- /**
- * <b>Configuration property:</b> Header section contents.
- *
- * <ul>
- * <li><b>Name:</b> <js>"HtmlDocSerializer.header"</js>
- * <li><b>Data type:</b> <code>String[]</code>
- * <li><b>Default:</b> <jk>null</jk>
- * <li><b>Session-overridable:</b> <jk>true</jk>
- * </ul>
- *
- * <p>
- * Allows you to override the contents of the header section on the HTML page.
- * The header section normally contains the title and description at the top of the page.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode'>
- * <ja>@RestResource</ja>(
- * htmldoc=<ja>@HtmlDoc</ja>(
- * header={
- * <js>"<h1>My own header</h1>"</js>
- * }
- * )
- * )
- * </p>
- */
- public static final String HTMLDOC_header = PREFIX + "header.list";
-
- /**
- * <b>Configuration property:</b> Page navigation links.
- *
- * <ul>
- * <li><b>Name:</b> <js>"HtmlDocSerializer.navlinks.list"</js>
- * <li><b>Data type:</b> <code>String[]</code>
- * <li><b>Default:</b> empty array
- * <li><b>Session-overridable:</b> <jk>true</jk>
- * </ul>
- *
- * <p>
- * Adds a list of hyperlinks immediately under the title and description but above the content of the page.
- *
- * <p>
- * This can be used to provide convenient hyperlinks when viewing the REST interface from a browser.
- *
- * <p>
- * The value is an array of strings with two possible values:
- * <ul>
- * <li>A key-value pair representing a hyperlink label and href:
- * <br><js>"google: http://google.com"</js>
- * <li>Arbitrary HTML.
- * </ul>
- *
- * <p>
- * Relative URLs are considered relative to the servlet path.
- * For example, if the servlet path is <js>"http://localhost/myContext/myServlet"</js>, and the
- * URL is <js>"foo"</js>, the link becomes <js>"http://localhost/myContext/myServlet/foo"</js>.
- * Absolute (<js>"/myOtherContext/foo"</js>) and fully-qualified (<js>"http://localhost2/foo"</js>) URLs
- * can also be used in addition to various other protocols specified by {@link UriResolver} such as
- * <js>"servlet:/..."</js>.
- *
- * <h5 class='section'>Example:</h5>
- * <p>
- * The <code>AddressBookResource</code> sample class uses this property...
- * <p class='bcode'>
- * <ja>@RestResource</ja>(
- * properties={
- * <ja>@Property</ja>(name=HtmlDocSerializerContext.<jsf>HTMLDOC_navlinks</jsf>,
- * value=<js>"['options: ?method=OPTIONS', 'doc: doc']"</js>)
- * }
- * )
- * <jk>public class</jk> AddressBookResource <jk>extends</jk> RestServletJenaDefault {
- * </p>
- *
- * <p>
- * ...to produce this list of links on the HTML page...
- * <img class='bordered' src='doc-files/HTML_LINKS.png'>
- *
- * <p>
- * A shortcut on <ja>@RestResource</ja> is also provided for this setting:
- * <p class='bcode'>
- * <ja>@RestResource</ja>(
- * htmldoc=@HtmlDoc(
- * navlinks={
- * <js>"options: ?method=OPTIONS"</js>,
- * <js>"doc: doc"</js>
- * }
- * )
- * )
- * <jk>public class</jk> AddressBookResource <jk>extends</jk> RestServletJenaDefault {
- * </p>
- */
- public static final String HTMLDOC_navlinks = PREFIX + "navlinks.list";
-
- /**
- * <b>Configuration property:</b> Add to the {@link #HTMLDOC_navlinks} property.
- */
- public static final String HTMLDOC_navlinks_add = PREFIX + "navlinks.list.add";
-
- /**
- * <b>Configuration property:</b> Nav section contents.
- *
- * <ul>
- * <li><b>Name:</b> <js>"HtmlDocSerializer.nav"</js>
- * <li><b>Data type:</b> <code>String[]</code>
- * <li><b>Default:</b> <jk>null</jk>
- * <li><b>Session-overridable:</b> <jk>true</jk>
- * </ul>
- *
- * <p>
- * Allows you to override the contents of the nav section on the HTML page.
- * The nav section normally contains the page links at the top of the page.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode'>
- * <ja>@RestResource</ja>(
- * htmldoc=<ja>@HtmlDoc</ja>(
- * nav={
- * <js>"<p class='special-navigation'>This is my special navigation content</p>"</js>
- * }
- * )
- * )
- * </p>
- *
- * <p>
- * When this property is specified, the {@link #HTMLDOC_navlinks} property is ignored.
- */
- public static final String HTMLDOC_nav = PREFIX + "nav.list";
-
- /**
- * <b>Configuration property:</b> Aside section contents.
- *
- * <ul>
- * <li><b>Name:</b> <js>"HtmlDocSerializer.aside"</js>
- * <li><b>Data type:</b> <code>String[]</code>
- * <li><b>Default:</b> <jk>null</jk>
- * <li><b>Session-overridable:</b> <jk>true</jk>
- * </ul>
- *
- * <p>
- * Allows you to specify the contents of the aside section on the HTML page.
- * The aside section floats on the right of the page for providing content supporting the serialized content of
- * the page.
- *
- * <p>
- * By default, the aside section is empty.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode'>
- * <ja>@RestResource</ja>(
- * htmldoc=<ja>@HtmlDoc</ja>(
- * aside={
- * <js>"<ul>"</js>,
- * <js>" <li>Item 1"</js>,
- * <js>" <li>Item 2"</js>,
- * <js>" <li>Item 3"</js>,
- * <js>"</ul>"</js>
- * }
- * )
- * )
- * </p>
- */
- public static final String HTMLDOC_aside = PREFIX + "aside.list";
-
- /**
- * <b>Configuration property:</b> Footer section contents.
- *
- * <ul>
- * <li><b>Name:</b> <js>"HtmlDocSerializer.footer"</js>
- * <li><b>Data type:</b> <code>String[]</code>
- * <li><b>Default:</b> <jk>null</jk>
- * <li><b>Session-overridable:</b> <jk>true</jk>
- * </ul>
- *
- * <p>
- * Allows you to specify the contents of the footer section on the HTML page.
- *
- * <p>
- * By default, the footer section is empty.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode'>
- * <ja>@RestResource</ja>(
- * htmldoc=<ja>@HtmlDoc</ja>(
- * footer={
- * <js>"<b>This interface is great!</b>"</js>
- * }
- * )
- * )
- * </p>
- */
- public static final String HTMLDOC_footer = PREFIX + "footer.list";
-
- /**
- * <b>Configuration property:</b> No-results message.
- *
- * <ul>
- * <li><b>Name:</b> <js>"HtmlDocSerializer.noResultsMessage"</js>
- * <li><b>Data type:</b> <code>String</code>
- * <li><b>Default:</b> <js>"<p>no results</p>"</js>
- * <li><b>Session-overridable:</b> <jk>true</jk>
- * </ul>
- *
- * <p>
- * Allows you to specify the string message used when trying to serialize an empty array or empty list.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode'>
- * <ja>@RestResource</ja>(
- * htmldoc=<ja>@HtmlDoc</ja>(
- * noResultsMessage=<js>"<b>This interface is great!</b>"</js>
- * )
- * )
- * </p>
- *
- * <p>
- * A value of <js>"NONE"</js> can be used to represent no value to differentiate it from an empty string.
- */
- public static final String HTMLDOC_noResultsMessage = PREFIX + "noResultsMessage";
-
- /**
- * <b>Configuration property:</b> Prevent word wrap on page.
- *
- * <ul>
- * <li><b>Name:</b> <js>"HtmlDocSerializer.nowrap"</js>
- * <li><b>Data type:</b> <code>Boolean</code>
- * <li><b>Default:</b> <jk>false</jk>
- * <li><b>Session-overridable:</b> <jk>true</jk>
- * </ul>
- *
- * <p>
- * Adds <js>"* {white-space:nowrap}"</js> to the CSS instructions on the page to prevent word wrapping.
- */
- public static final String HTMLDOC_nowrap = PREFIX + "nowrap";
-
- /**
- * <b>Configuration property:</b> Stylesheet import URLs.
- *
- * <ul>
- * <li><b>Name:</b> <js>"HtmlDocSerializer.stylesheet"</js>
- * <li><b>Data type:</b> <code>String[]</code>
- * <li><b>Default:</b> empty array
- * <li><b>Session-overridable:</b> <jk>true</jk>
- * </ul>
- *
- * <p>
- * Adds a link to the specified stylesheet URL.
- *
- * <p>
- * Note that this stylesheet is controlled by the <code><ja>@RestResource</ja>.stylesheet()</code> annotation.
- */
- public static final String HTMLDOC_stylesheet = PREFIX + "stylesheet.list";
-
- /**
- * <b>Configuration property:</b> Add to the {@link #HTMLDOC_stylesheet} property.
- */
- public static final String HTMLDOC_stylesheet_add = PREFIX + "stylesheet.list.add";
-
- /**
- * <b>Configuration property:</b> CSS style code.
- *
- * <ul>
- * <li><b>Name:</b> <js>"HtmlDocSerializer.style.list"</js>
- * <li><b>Data type:</b> <code>String[]</code>
- * <li><b>Default:</b> empty array
- * <li><b>Session-overridable:</b> <jk>true</jk>
- * </ul>
- *
- * <p>
- * Adds the specified CSS instructions to the HTML page.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode'>
- * <ja>@RestResource</ja>(
- * properties={
- * <ja>@Property</ja>(name=HtmlDocSerializerContext.<jsf>HTMLDOC_style</jsf>,
- * value=<js>"h3 { color: red; }\nh5 { font-weight: bold; }"</js>)
- * }
- * )
- * </p>
- *
- * <p>
- * A shortcut on <ja>@RestResource</ja> is also provided for this setting:
- * <p class='bcode'>
- * <ja>@RestResource</ja>(
- * htmldoc=@HtmlDoc(
- * style={
- * <js>"h3 { color: red; }"</js>,
- * <js>"h5 { font-weight: bold; }"</js>
- * }
- * )
- * )
- * </p>
- */
- public static final String HTMLDOC_style = PREFIX + "style.list";
-
- /**
- * <b>Configuration property:</b> Add to the {@link #HTMLDOC_style} property.
- */
- public static final String HTMLDOC_style_add = PREFIX + "style.list.add";
-
- /**
- * <b>Configuration property:</b> Javascript code.
- *
- * <ul>
- * <li><b>Name:</b> <js>"HtmlDocSerializer.script.list"</js>
- * <li><b>Data type:</b> <code>String[]</code>
- * <li><b>Default:</b> empty array
- * <li><b>Session-overridable:</b> <jk>true</jk>
- * </ul>
- *
- * <p>
- * Adds the specified Javascript code to the HTML page.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode'>
- * <ja>@RestResource</ja>(
- * properties={
- * <ja>@Property</ja>(name=HtmlDocSerializerContext.<jsf>HTMLDOC_script</jsf>,
- * value=<js>"alert('hello!');"</js>)
- * }
- * )
- * </p>
- *
- * <p>
- * A shortcut on <ja>@RestResource</ja> is also provided for this setting:
- * <p class='bcode'>
- * <ja>@RestResource</ja>(
- * htmldoc=@HtmlDoc(
- * script={
- * <js>"alert('hello!');"</js>
- * }
- * )
- * )
- * </p>
- */
- public static final String HTMLDOC_script = PREFIX + "script.list";
-
- /**
- * <b>Configuration property:</b> Add to the {@link #HTMLDOC_script} property.
- */
- public static final String HTMLDOC_script_add = PREFIX + "script.list.add";
-
- /**
- * <b>Configuration property:</b> Additional head section content.
- *
- * <ul>
- * <li><b>Name:</b> <js>"HtmlDocSerializer.head.list"</js>
- * <li><b>Data type:</b> <code>String[]</code>
- * <li><b>Default:</b> empty array
- * <li><b>Session-overridable:</b> <jk>true</jk>
- * </ul>
- *
- * <p>
- * Adds the specified HTML content to the head section of the page.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode'>
- * <ja>@RestResource</ja>(
- * properties={
- * <ja>@Property</ja>(name=HtmlDocSerializerContext.<jsf>HTMLDOC_links</jsf>,
- * value=<js>"['<link rel=\"icon\" href=\"htdocs/mypageicon.ico\">']"</js>)
- * }
- * )
- * </p>
- *
- * <p>
- * A shortcut on <ja>@RestResource</ja> is also provided for this setting:
- * <p class='bcode'>
- * <ja>@RestResource</ja>(
- * htmldoc=@HtmlDoc(
- * head={
- * <js>"<link rel='icon' href='$U{servlet:/htdocs/mypageicon.ico}'>"</js>
- * }
- * )
- * )
- * </p>
- */
- public static final String HTMLDOC_head = PREFIX + "head.list";
-
- /**
- * <b>Configuration property:</b> Add to the {@link #HTMLDOC_head} property.
- */
- public static final String HTMLDOC_links_add = PREFIX + "head.list.add";
-
- /**
- * <b>Configuration property:</b> HTML document template.
- *
- * <ul>
- * <li><b>Name:</b> <js>"HtmlDocSerializer.template"</js>
- * <li><b>Data type:</b> <code>Class<? <jk>extends</jk> HtmlDocTemplate></code> or {@link HtmlDocTemplate}
- * <li><b>Default:</b> <code>HtmlDocTemplateBasic.<jk>class</jk></code>
- * <li><b>Session-overridable:</b> <jk>true</jk>
- * </ul>
- *
- * <p>
- * Specifies the template to use for serializing the page.
- *
- * <p>
- * By default, the {@link HtmlDocTemplateBasic} class is used to construct the contents of the HTML page, but
- * can be overridden with your own custom implementation class.
- *
- * <h5 class='section'>Example:</h5>
- * <p class='bcode'>
- * <ja>@RestResource</ja>(
- * htmldoc=@HtmlDoc(
- * template=MySpecialDocTemplate.<jk>class</jk>
- * )
- * )
- * </p>
- */
- public static final String HTMLDOC_template = PREFIX + "template";
-
-
final String[] style, stylesheet, script, navlinks, head, header, nav, aside, footer;
final String noResultsMessage;
final boolean nowrap;
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d22f1b26/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java
index 007c260..3405483 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlDocSerializerSession.java
@@ -12,7 +12,7 @@
// ***************************************************************************************************************************
package org.apache.juneau.html;
-import static org.apache.juneau.html.HtmlDocSerializerContext.*;
+import static org.apache.juneau.html.HtmlDocSerializer.*;
import org.apache.juneau.*;
import org.apache.juneau.internal.*;
@@ -81,10 +81,10 @@ public class HtmlDocSerializerSession extends HtmlStrippedDocSerializerSession {
}
/**
- * Returns the {@link HtmlDocSerializerContext#HTMLDOC_style} setting value in this context.
+ * Returns the {@link HtmlDocSerializer#HTMLDOC_style} setting value in this context.
*
* @return
- * The {@link HtmlDocSerializerContext#HTMLDOC_style} setting value in this context.
+ * The {@link HtmlDocSerializer#HTMLDOC_style} setting value in this context.
* An empty array if not specified.
* Never <jk>null</jk>.
*/
@@ -93,10 +93,10 @@ public class HtmlDocSerializerSession extends HtmlStrippedDocSerializerSession {
}
/**
- * Returns the {@link HtmlDocSerializerContext#HTMLDOC_stylesheet} setting value in this context.
+ * Returns the {@link HtmlDocSerializer#HTMLDOC_stylesheet} setting value in this context.
*
* @return
- * The {@link HtmlDocSerializerContext#HTMLDOC_stylesheet} setting value in this context.
+ * The {@link HtmlDocSerializer#HTMLDOC_stylesheet} setting value in this context.
* An empty array if not specified.
* Never <jk>null</jk>.
*/
@@ -105,10 +105,10 @@ public class HtmlDocSerializerSession extends HtmlStrippedDocSerializerSession {
}
/**
- * Returns the {@link HtmlDocSerializerContext#HTMLDOC_script} setting value in this context.
+ * Returns the {@link HtmlDocSerializer#HTMLDOC_script} setting value in this context.
*
* @return
- * The {@link HtmlDocSerializerContext#HTMLDOC_script} setting value in this context.
+ * The {@link HtmlDocSerializer#HTMLDOC_script} setting value in this context.
* An empty array if not specified.
* Never <jk>null</jk>.
*/
@@ -117,10 +117,10 @@ public class HtmlDocSerializerSession extends HtmlStrippedDocSerializerSession {
}
/**
- * Returns the {@link HtmlDocSerializerContext#HTMLDOC_head} setting value in this context.
+ * Returns the {@link HtmlDocSerializer#HTMLDOC_head} setting value in this context.
*
* @return
- * The {@link HtmlDocSerializerContext#HTMLDOC_head} setting value in this context.
+ * The {@link HtmlDocSerializer#HTMLDOC_head} setting value in this context.
* An empty array if not specified.
* Never <jk>null</jk>.
*/
@@ -129,19 +129,19 @@ public class HtmlDocSerializerSession extends HtmlStrippedDocSerializerSession {
}
/**
- * Returns the {@link HtmlDocSerializerContext#HTMLDOC_nowrap} setting value in this context.
+ * Returns the {@link HtmlDocSerializer#HTMLDOC_nowrap} setting value in this context.
*
- * @return The {@link HtmlDocSerializerContext#HTMLDOC_nowrap} setting value in this context.
+ * @return The {@link HtmlDocSerializer#HTMLDOC_nowrap} setting value in this context.
*/
public final boolean isNoWrap() {
return nowrap;
}
/**
- * Returns the {@link HtmlDocSerializerContext#HTMLDOC_header} setting value in this context.
+ * Returns the {@link HtmlDocSerializer#HTMLDOC_header} setting value in this context.
*
* @return
- * The {@link HtmlDocSerializerContext#HTMLDOC_header} setting value in this context.
+ * The {@link HtmlDocSerializer#HTMLDOC_header} setting value in this context.
* <jk>null</jk> if not specified.
* Never an empty string.
*/
@@ -150,10 +150,10 @@ public class HtmlDocSerializerSession extends HtmlStrippedDocSerializerSession {
}
/**
- * Returns the {@link HtmlDocSerializerContext#HTMLDOC_navlinks} setting value in this context.
+ * Returns the {@link HtmlDocSerializer#HTMLDOC_navlinks} setting value in this context.
*
* @return
- * The {@link HtmlDocSerializerContext#HTMLDOC_navlinks} setting value in this context.
+ * The {@link HtmlDocSerializer#HTMLDOC_navlinks} setting value in this context.
* <jk>null</jk> if not specified.
* Never an empty map.
*/
@@ -173,10 +173,10 @@ public class HtmlDocSerializerSession extends HtmlStrippedDocSerializerSession {
}
/**
- * Returns the {@link HtmlDocSerializerContext#HTMLDOC_nav} setting value in this context.
+ * Returns the {@link HtmlDocSerializer#HTMLDOC_nav} setting value in this context.
*
* @return
- * The {@link HtmlDocSerializerContext#HTMLDOC_nav} setting value in this context.
+ * The {@link HtmlDocSerializer#HTMLDOC_nav} setting value in this context.
* <jk>null</jk> if not specified.
* Never an empty string.
*/
@@ -185,10 +185,10 @@ public class HtmlDocSerializerSession extends HtmlStrippedDocSerializerSession {
}
/**
- * Returns the {@link HtmlDocSerializerContext#HTMLDOC_aside} setting value in this context.
+ * Returns the {@link HtmlDocSerializer#HTMLDOC_aside} setting value in this context.
*
* @return
- * The {@link HtmlDocSerializerContext#HTMLDOC_aside} setting value in this context.
+ * The {@link HtmlDocSerializer#HTMLDOC_aside} setting value in this context.
* <jk>null</jk> if not specified.
* Never an empty string.
*/
@@ -197,10 +197,10 @@ public class HtmlDocSerializerSession extends HtmlStrippedDocSerializerSession {
}
/**
- * Returns the {@link HtmlDocSerializerContext#HTMLDOC_footer} setting value in this context.
+ * Returns the {@link HtmlDocSerializer#HTMLDOC_footer} setting value in this context.
*
* @return
- * The {@link HtmlDocSerializerContext#HTMLDOC_footer} setting value in this context.
+ * The {@link HtmlDocSerializer#HTMLDOC_footer} setting value in this context.
* <jk>null</jk> if not specified.
* Never an empty string.
*/
@@ -209,10 +209,10 @@ public class HtmlDocSerializerSession extends HtmlStrippedDocSerializerSession {
}
/**
- * Returns the {@link HtmlDocSerializerContext#HTMLDOC_noResultsMessage} setting value in this context.
+ * Returns the {@link HtmlDocSerializer#HTMLDOC_noResultsMessage} setting value in this context.
*
* @return
- * The {@link HtmlDocSerializerContext#HTMLDOC_noResultsMessage} setting value in this context.
+ * The {@link HtmlDocSerializer#HTMLDOC_noResultsMessage} setting value in this context.
* <jk>null</jk> if not specified.
* Never an empty string.
*/
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d22f1b26/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParser.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParser.java
index a18dbc4..6d88fb2 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParser.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParser.java
@@ -28,21 +28,22 @@ import org.apache.juneau.xml.*;
* See the {@link HtmlSerializer} class for a description of the HTML generated.
* <p>
* This class is used primarily for automated testing of the {@link HtmlSerializer} class.
- *
- * <h5 class='section'>Configurable properties:</h5>
- *
- * This class has the following properties associated with it:
- * <ul>
- * <li>{@link HtmlSerializerContext}
- * </ul>
*/
@SuppressWarnings({ "hiding" })
public class HtmlParser extends XmlParser {
+ //-------------------------------------------------------------------------------------------------------------------
+ // Predefined instances
+ //-------------------------------------------------------------------------------------------------------------------
+
/** Default parser, all default settings.*/
public static final HtmlParser DEFAULT = new HtmlParser(PropertyStore.create());
+ //-------------------------------------------------------------------------------------------------------------------
+ // Instance
+ //-------------------------------------------------------------------------------------------------------------------
+
private final HtmlParserContext ctx;
/**
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d22f1b26/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserContext.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserContext.java
index e1abc7f..399a3a2 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserContext.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserContext.java
@@ -16,27 +16,7 @@ import org.apache.juneau.*;
import org.apache.juneau.xml.*;
/**
- * Configurable properties on the {@link HtmlParser} class.
- *
- * <p>
- * Context properties are set by calling {@link PropertyStore#setProperty(String, Object)} on the property store
- * passed into the constructor.
- *
- * <p>
- * See {@link PropertyStore} for more information about context properties.
- *
- * <h6 class='topic'>Inherited configurable properties</h6>
- * <ul class='doctree'>
- * <li class='jc'>
- * <a class="doclink" href="../BeanContext.html#ConfigProperties">BeanContext</a>
- * - Properties associated with handling beans on serializers and parsers.
- * <ul>
- * <li class='jc'>
- * <a class="doclink" href="../parser/ParserContext.html#ConfigProperties">ParserContext</a>
- * - Configurable properties common to all parsers.
- * </ul>
- * </li>
- * </ul>
+ * Contains a snapshot-in-time read-only copy of the settings on the {@link HtmlParser} class.
*/
public final class HtmlParserContext extends XmlParserContext {
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d22f1b26/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSchemaDocSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSchemaDocSerializer.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSchemaDocSerializer.java
index a20778c..4eff575 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSchemaDocSerializer.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSchemaDocSerializer.java
@@ -12,8 +12,6 @@
// ***************************************************************************************************************************
package org.apache.juneau.html;
-import static org.apache.juneau.serializer.SerializerContext.*;
-
import org.apache.juneau.*;
import org.apache.juneau.serializer.*;
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d22f1b26/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializer.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializer.java
index 9a1f302..a446497 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializer.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializer.java
@@ -12,8 +12,6 @@
// ***************************************************************************************************************************
package org.apache.juneau.html;
-import static org.apache.juneau.serializer.SerializerContext.*;
-
import java.util.*;
import org.apache.juneau.*;
@@ -54,14 +52,6 @@ import org.apache.juneau.xml.*;
* <p>
* The {@link HtmlLink} annotation can be used on beans to add hyperlinks to the output.
*
- * <h5 class='section'>Configurable properties:</h5>
- *
- * This class has the following properties associated with it:
- * <ul class='spaced-list'>
- * <li>
- * {@link HtmlSerializerContext}
- * </ul>
- *
* <h6 class='topic'>Behavior-specific subclasses</h6>
*
* The following direct subclasses are provided for convenience:
@@ -135,6 +125,117 @@ import org.apache.juneau.xml.*;
@SuppressWarnings("hiding")
public class HtmlSerializer extends XmlSerializer {
+ //-------------------------------------------------------------------------------------------------------------------
+ // Configurable properties
+ //-------------------------------------------------------------------------------------------------------------------
+
+ private static final String PREFIX = "HtmlSerializer.";
+
+ /**
+ * <b>Configuration property:</b> Anchor text source.
+ *
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlSerializer.uriAnchorText"</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>
+ *
+ * <p>
+ * When creating anchor tags (e.g. <code><xt><a</xt> <xa>href</xa>=<xs>'...'</xs>
+ * <xt>></xt>text<xt></a></xt></code>) in HTML, this setting defines what to set the inner text to.
+ *
+ * <p>
+ * See the {@link AnchorText} enum for possible values.
+ */
+ public static final String HTML_uriAnchorText = PREFIX + "uriAnchorText";
+
+ /**
+ * <b>Configuration property:</b> Look for URLs in {@link String Strings}.
+ *
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlSerializer.detectLinksInStrings"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>true</jk>
+ * <li><b>Session-overridable:</b> <jk>true</jk>
+ * </ul>
+ *
+ * <p>
+ * If a string looks like a URL (e.g. starts with <js>"http://"</js> or <js>"https://"</js>, then treat it like a URL
+ * and make it into a hyperlink based on the rules specified by {@link #HTML_uriAnchorText}.
+ */
+ public static final String HTML_detectLinksInStrings = PREFIX + "detectLinksInStrings";
+
+ /**
+ * <b>Configuration property:</b> Look for link labels in the <js>"label"</js> parameter of the URL.
+ *
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlSerializer.lookForLabelParameters"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>true</jk>
+ * <li><b>Session-overridable:</b> <jk>true</jk>
+ * </ul>
+ *
+ * <p>
+ * If the URL has a label parameter (e.g. <js>"?label=foobar"</js>), then use that as the anchor text of the link.
+ *
+ * <p>
+ * The parameter name can be changed via the {@link #HTML_labelParameter} property.
+ */
+ public static final String HTML_lookForLabelParameters = PREFIX + "lookForLabelParameters";
+
+ /**
+ * <b>Configuration property:</b> The parameter name to use when using {@link #HTML_lookForLabelParameters}.
+ *
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlSerializer.labelParameter"</js>
+ * <li><b>Data type:</b> <code>String</code>
+ * <li><b>Default:</b> <js>"label"</js>
+ * <li><b>Session-overridable:</b> <jk>true</jk>
+ * </ul>
+ */
+ public static final String HTML_labelParameter = PREFIX + "labelParameter";
+
+ /**
+ * <b>Configuration property:</b> Add key/value headers on bean/map tables.
+ *
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlSerializer.addKeyValueTableHeaders"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * <li><b>Session-overridable:</b> <jk>true</jk>
+ * </ul>
+ */
+ public static final String HTML_addKeyValueTableHeaders = PREFIX + "addKeyValueTableHeaders";
+
+ /**
+ * <b>Configuration property:</b> Add <js>"_type"</js> properties when needed.
+ *
+ * <ul>
+ * <li><b>Name:</b> <js>"HtmlSerializer.addBeanTypeProperties"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * <li><b>Session-overridable:</b> <jk>true</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.
+ * For example, when serializing a {@code Map<String,Object>} field, where the bean class cannot be determined
+ * from the value type.
+ *
+ * <p>
+ * When present, this value overrides the {@link #SERIALIZER_addBeanTypeProperties} setting and is
+ * provided to customize the behavior of specific serializers in a {@link SerializerGroup}.
+ */
+ public static final String HTML_addBeanTypeProperties = PREFIX + "addBeanTypeProperties";
+
+
+ //-------------------------------------------------------------------------------------------------------------------
+ // Predefined instances
+ //-------------------------------------------------------------------------------------------------------------------
+
/** Default serializer, all default settings. */
public static final HtmlSerializer DEFAULT = new HtmlSerializer(PropertyStore.create());
@@ -145,6 +246,10 @@ public class HtmlSerializer extends XmlSerializer {
public static final HtmlSerializer DEFAULT_SQ_READABLE = new HtmlSerializer.SqReadable(PropertyStore.create());
+ //-------------------------------------------------------------------------------------------------------------------
+ // Predefined subclasses
+ //-------------------------------------------------------------------------------------------------------------------
+
/** Default serializer, single quotes. */
public static class Sq extends HtmlSerializer {
@@ -172,6 +277,10 @@ public class HtmlSerializer extends XmlSerializer {
}
+ //-------------------------------------------------------------------------------------------------------------------
+ // Instance
+ //-------------------------------------------------------------------------------------------------------------------
+
final HtmlSerializerContext ctx;
private volatile HtmlSchemaDocSerializer schemaSerializer;
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d22f1b26/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 6acada7..dec298a 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
@@ -12,7 +12,7 @@
// ***************************************************************************************************************************
package org.apache.juneau.html;
-import static org.apache.juneau.html.HtmlSerializerContext.*;
+import static org.apache.juneau.html.HtmlSerializer.*;
import java.util.*;
@@ -76,7 +76,7 @@ public class HtmlSerializerBuilder extends XmlSerializerBuilder {
*
* @param value The new value for this property.
* @return This object (for method chaining).
- * @see HtmlSerializerContext#HTML_uriAnchorText
+ * @see HtmlSerializer#HTML_uriAnchorText
*/
public HtmlSerializerBuilder uriAnchorText(AnchorText value) {
return property(HTML_uriAnchorText, value);
@@ -94,7 +94,7 @@ public class HtmlSerializerBuilder extends XmlSerializerBuilder {
*
* <p>
* If a string looks like a URL (e.g. starts with <js>"http://"</js> or <js>"https://"</js>, then treat it like a URL
- * and make it into a hyperlink based on the rules specified by {@link HtmlSerializerContext#HTML_uriAnchorText}.
+ * and make it into a hyperlink based on the rules specified by {@link HtmlSerializer#HTML_uriAnchorText}.
*
* <h5 class='section'>Notes:</h5>
* <ul>
@@ -104,7 +104,7 @@ public class HtmlSerializerBuilder extends XmlSerializerBuilder {
*
* @param value The new value for this property.
* @return This object (for method chaining).
- * @see HtmlSerializerContext#HTML_detectLinksInStrings
+ * @see HtmlSerializer#HTML_detectLinksInStrings
*/
public HtmlSerializerBuilder detectLinksInStrings(boolean value) {
return property(HTML_detectLinksInStrings, value);
@@ -124,7 +124,7 @@ public class HtmlSerializerBuilder extends XmlSerializerBuilder {
* If the URL has a label parameter (e.g. <js>"?label=foobar"</js>), then use that as the anchor text of the link.
*
* <p>
- * The parameter name can be changed via the {@link HtmlSerializerContext#HTML_labelParameter} property.
+ * The parameter name can be changed via the {@link HtmlSerializer#HTML_labelParameter} property.
*
* <h5 class='section'>Notes:</h5>
* <ul>
@@ -134,14 +134,14 @@ public class HtmlSerializerBuilder extends XmlSerializerBuilder {
*
* @param value The new value for this property.
* @return This object (for method chaining).
- * @see HtmlSerializerContext#HTML_lookForLabelParameters
+ * @see HtmlSerializer#HTML_lookForLabelParameters
*/
public HtmlSerializerBuilder lookForLabelParameters(boolean value) {
return property(HTML_lookForLabelParameters, value);
}
/**
- * <b>Configuration property:</b> The parameter name to use when using {@link HtmlSerializerContext#HTML_lookForLabelParameters}.
+ * <b>Configuration property:</b> The parameter name to use when using {@link HtmlSerializer#HTML_lookForLabelParameters}.
*
* <ul>
* <li><b>Name:</b> <js>"HtmlSerializer.labelParameter"</js>
@@ -158,7 +158,7 @@ public class HtmlSerializerBuilder extends XmlSerializerBuilder {
*
* @param value The new value for this property.
* @return This object (for method chaining).
- * @see HtmlSerializerContext#HTML_labelParameter
+ * @see HtmlSerializer#HTML_labelParameter
*/
public HtmlSerializerBuilder labelParameter(String value) {
return property(HTML_labelParameter, value);
@@ -182,7 +182,7 @@ public class HtmlSerializerBuilder extends XmlSerializerBuilder {
*
* @param value The new value for this property.
* @return This object (for method chaining).
- * @see HtmlSerializerContext#HTML_addKeyValueTableHeaders
+ * @see HtmlSerializer#HTML_addKeyValueTableHeaders
*/
public HtmlSerializerBuilder addKeyValueTableHeaders(boolean value) {
return property(HTML_addKeyValueTableHeaders, value);
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d22f1b26/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 2749b51..8bb191b 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
@@ -12,138 +12,16 @@
// ***************************************************************************************************************************
package org.apache.juneau.html;
+import static org.apache.juneau.html.HtmlSerializer.*;
+
import org.apache.juneau.*;
-import org.apache.juneau.serializer.*;
import org.apache.juneau.xml.*;
/**
- * Configurable properties on the {@link HtmlSerializer} class.
- *
- * <p>
- * Context properties are set by calling {@link PropertyStore#setProperty(String, Object)} on the property store
- * passed into the constructor.
- *
- * <p>
- * See {@link PropertyStore} for more information about context properties.
- *
- * <h6 class='topic'>Inherited configurable properties</h6>
- * <ul class='doctree'>
- * <li class='jc'>
- * <a class="doclink" href="../BeanContext.html#ConfigProperties">BeanContext</a>
- * - Properties associated with handling beans on serializers and parsers.
- * <ul>
- * <li class='jc'>
- * <a class="doclink" href="../serializer/SerializerContext.html#ConfigProperties">SerializerContext</a>
- * - Configurable properties common to all serializers.
- * </ul>
- * </li>
- * </ul>
+ * Contains a snapshot-in-time read-only copy of the settings on the {@link HtmlSerializer} class.
*/
public class HtmlSerializerContext extends XmlSerializerContext {
- static final String PREFIX = "HtmlSerializer.";
-
- /**
- * <b>Configuration property:</b> Anchor text source.
- *
- * <ul>
- * <li><b>Name:</b> <js>"HtmlSerializer.uriAnchorText"</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>
- *
- * <p>
- * When creating anchor tags (e.g. <code><xt><a</xt> <xa>href</xa>=<xs>'...'</xs>
- * <xt>></xt>text<xt></a></xt></code>) in HTML, this setting defines what to set the inner text to.
- *
- * <p>
- * See the {@link AnchorText} enum for possible values.
- */
- public static final String HTML_uriAnchorText = PREFIX + "uriAnchorText";
-
- /**
- * <b>Configuration property:</b> Look for URLs in {@link String Strings}.
- *
- * <ul>
- * <li><b>Name:</b> <js>"HtmlSerializer.detectLinksInStrings"</js>
- * <li><b>Data type:</b> <code>Boolean</code>
- * <li><b>Default:</b> <jk>true</jk>
- * <li><b>Session-overridable:</b> <jk>true</jk>
- * </ul>
- *
- * <p>
- * If a string looks like a URL (e.g. starts with <js>"http://"</js> or <js>"https://"</js>, then treat it like a URL
- * and make it into a hyperlink based on the rules specified by {@link #HTML_uriAnchorText}.
- */
- public static final String HTML_detectLinksInStrings = PREFIX + "detectLinksInStrings";
-
- /**
- * <b>Configuration property:</b> Look for link labels in the <js>"label"</js> parameter of the URL.
- *
- * <ul>
- * <li><b>Name:</b> <js>"HtmlSerializer.lookForLabelParameters"</js>
- * <li><b>Data type:</b> <code>Boolean</code>
- * <li><b>Default:</b> <jk>true</jk>
- * <li><b>Session-overridable:</b> <jk>true</jk>
- * </ul>
- *
- * <p>
- * If the URL has a label parameter (e.g. <js>"?label=foobar"</js>), then use that as the anchor text of the link.
- *
- * <p>
- * The parameter name can be changed via the {@link #HTML_labelParameter} property.
- */
- public static final String HTML_lookForLabelParameters = PREFIX + "lookForLabelParameters";
-
- /**
- * <b>Configuration property:</b> The parameter name to use when using {@link #HTML_lookForLabelParameters}.
- *
- * <ul>
- * <li><b>Name:</b> <js>"HtmlSerializer.labelParameter"</js>
- * <li><b>Data type:</b> <code>String</code>
- * <li><b>Default:</b> <js>"label"</js>
- * <li><b>Session-overridable:</b> <jk>true</jk>
- * </ul>
- */
- public static final String HTML_labelParameter = PREFIX + "labelParameter";
-
- /**
- * <b>Configuration property:</b> Add key/value headers on bean/map tables.
- *
- * <ul>
- * <li><b>Name:</b> <js>"HtmlSerializer.addKeyValueTableHeaders"</js>
- * <li><b>Data type:</b> <code>Boolean</code>
- * <li><b>Default:</b> <jk>false</jk>
- * <li><b>Session-overridable:</b> <jk>true</jk>
- * </ul>
- */
- public static final String HTML_addKeyValueTableHeaders = PREFIX + "addKeyValueTableHeaders";
-
- /**
- * <b>Configuration property:</b> Add <js>"_type"</js> properties when needed.
- *
- * <ul>
- * <li><b>Name:</b> <js>"HtmlSerializer.addBeanTypeProperties"</js>
- * <li><b>Data type:</b> <code>Boolean</code>
- * <li><b>Default:</b> <jk>false</jk>
- * <li><b>Session-overridable:</b> <jk>true</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.
- * For example, when serializing a {@code Map<String,Object>} field, where the bean class cannot be determined
- * from the value type.
- *
- * <p>
- * When present, this value overrides the {@link SerializerContext#SERIALIZER_addBeanTypeProperties} setting and is
- * provided to customize the behavior of specific serializers in a {@link SerializerGroup}.
- */
- public static final String HTML_addBeanTypeProperties = PREFIX + "addBeanTypeProperties";
-
-
final AnchorText uriAnchorText;
final boolean
lookForLabelParameters,
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d22f1b26/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 9e9ae42..8906a0c 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
@@ -13,7 +13,7 @@
package org.apache.juneau.html;
import static org.apache.juneau.html.HtmlSerializerSession.ContentResult.*;
-import static org.apache.juneau.html.HtmlSerializerContext.*;
+import static org.apache.juneau.html.HtmlSerializer.*;
import static org.apache.juneau.xml.XmlUtils.*;
import java.io.*;
@@ -169,18 +169,18 @@ public class HtmlSerializerSession extends XmlSerializerSession {
}
/**
- * Returns the {@link HtmlSerializerContext#HTML_addKeyValueTableHeaders} setting value for this session.
+ * Returns the {@link HtmlSerializer#HTML_addKeyValueTableHeaders} setting value for this session.
*
- * @return The {@link HtmlSerializerContext#HTML_addKeyValueTableHeaders} setting value for this session.
+ * @return The {@link HtmlSerializer#HTML_addKeyValueTableHeaders} setting value for this session.
*/
public final boolean isAddKeyValueTableHeaders() {
return addKeyValueTableHeaders;
}
/**
- * Returns the {@link HtmlSerializerContext#HTML_addBeanTypeProperties} setting value for this session.
+ * Returns the {@link HtmlSerializer#HTML_addBeanTypeProperties} setting value for this session.
*
- * @return The {@link HtmlSerializerContext#HTML_addBeanTypeProperties} setting value for this session.
+ * @return The {@link HtmlSerializer#HTML_addBeanTypeProperties} setting value for this session.
*/
@Override /* SerializerSession */
public final boolean isAddBeanTypeProperties() {
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d22f1b26/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoParser.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoParser.java
index 835ca36..8b5666a 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoParser.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoParser.java
@@ -26,10 +26,18 @@ import org.apache.juneau.parser.*;
*/
public final class JsoParser extends InputStreamParser {
+ //-------------------------------------------------------------------------------------------------------------------
+ // Predefined instances
+ //-------------------------------------------------------------------------------------------------------------------
+
/** Default parser, all default settings.*/
public static final JsoParser DEFAULT = new JsoParser(PropertyStore.create());
+ //-------------------------------------------------------------------------------------------------------------------
+ // Instance
+ //-------------------------------------------------------------------------------------------------------------------
+
/**
* Constructor.
*
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d22f1b26/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoSerializer.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoSerializer.java
index 2fa50fb..e56c279 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoSerializer.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jso/JsoSerializer.java
@@ -29,9 +29,18 @@ import org.apache.juneau.serializer.*;
*/
public class JsoSerializer extends OutputStreamSerializer {
+ //-------------------------------------------------------------------------------------------------------------------
+ // Predefined instances
+ //-------------------------------------------------------------------------------------------------------------------
+
/** Default serializer, all default settings.*/
public static final JsoSerializer DEFAULT = new JsoSerializer(PropertyStore.create());
+
+ //-------------------------------------------------------------------------------------------------------------------
+ // Instance
+ //-------------------------------------------------------------------------------------------------------------------
+
private final SerializerContext ctx;
/**
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d22f1b26/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParser.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParser.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParser.java
index 5fa9c85..98f05c7 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParser.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParser.java
@@ -12,8 +12,6 @@
// ***************************************************************************************************************************
package org.apache.juneau.json;
-import static org.apache.juneau.parser.ParserContext.*;
-
import org.apache.juneau.*;
import org.apache.juneau.parser.*;
@@ -99,22 +97,24 @@ import org.apache.juneau.parser.*;
* {@link ObjectMap#ObjectMap(CharSequence) ObjectMap(CharSequence)} or {@link ObjectList#ObjectList(CharSequence)
* ObjectList(CharSequence)} constructors instead of using this class.
* The end result should be the same.
- *
- * <h5 class='section'>Configurable properties:</h5>
- *
- * This class has the following properties associated with it:
- * <ul>
- * <li>{@link JsonParserContext}
- * </ul>
*/
public class JsonParser extends ReaderParser {
+ //-------------------------------------------------------------------------------------------------------------------
+ // Predefined instances
+ //-------------------------------------------------------------------------------------------------------------------
+
/** Default parser, all default settings.*/
public static final JsonParser DEFAULT = new JsonParser(PropertyStore.create());
/** Default parser, all default settings.*/
public static final JsonParser DEFAULT_STRICT = new JsonParser.Strict(PropertyStore.create());
+
+ //-------------------------------------------------------------------------------------------------------------------
+ // Predefined subclasses
+ //-------------------------------------------------------------------------------------------------------------------
+
/** Default parser, strict mode. */
public static class Strict extends JsonParser {
@@ -129,6 +129,10 @@ public class JsonParser extends ReaderParser {
}
+ //-------------------------------------------------------------------------------------------------------------------
+ // Instance
+ //-------------------------------------------------------------------------------------------------------------------
+
private final JsonParserContext ctx;
/**
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d22f1b26/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserContext.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserContext.java
index 66977f3..af8ab7a 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserContext.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonParserContext.java
@@ -16,27 +16,7 @@ import org.apache.juneau.*;
import org.apache.juneau.parser.*;
/**
- * Configurable properties on the {@link JsonParser} class.
- *
- * <p>
- * Context properties are set by calling {@link PropertyStore#setProperty(String, Object)} on the property store
- * passed into the constructor.
- *
- * <p>
- * See {@link PropertyStore} for more information about context properties.
- *
- * <h6 class='topic'>Inherited configurable properties</h6>
- * <ul class='doctree'>
- * <li class='jc'>
- * <a class="doclink" href="../BeanContext.html#ConfigProperties">BeanContext</a>
- * - Properties associated with handling beans on serializers and parsers.
- * <ul>
- * <li class='jc'>
- * <a class="doclink" href="../parser/ParserContext.html#ConfigProperties">ParserContext</a>
- * - Configurable properties common to all parsers.
- * </ul>
- * </li>
- * </ul>
+ * Contains a snapshot-in-time read-only copy of the settings on the {@link JsonParser} class.
*/
public final class JsonParserContext extends ParserContext {
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d22f1b26/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSchemaSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSchemaSerializer.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSchemaSerializer.java
index 42ae307..c8d55ee 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSchemaSerializer.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSchemaSerializer.java
@@ -12,8 +12,6 @@
// ***************************************************************************************************************************
package org.apache.juneau.json;
-import static org.apache.juneau.serializer.SerializerContext.*;
-
import org.apache.juneau.*;
import org.apache.juneau.serializer.*;
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d22f1b26/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializer.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializer.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializer.java
index 5336f7b..ed0141e 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializer.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializer.java
@@ -12,8 +12,6 @@
// ***************************************************************************************************************************
package org.apache.juneau.json;
-import static org.apache.juneau.json.JsonSerializerContext.*;
-
import java.util.*;
import org.apache.juneau.*;
@@ -63,15 +61,6 @@ import org.apache.juneau.serializer.*;
* Typically, one of the predefined DEFAULT serializers will be sufficient.
* However, custom serializers can be constructed to fine-tune behavior.
*
- * <h5 class='section'>Configurable properties:</h5>
- *
- * This class has the following properties associated with it:
- * <ul>
- * <li>{@link JsonSerializerContext}
- * <li>{@link SerializerContext}
- * <li>{@link BeanContext}
- * </ul>
- *
* <h6 class='topic'>Behavior-specific subclasses</h6>
*
* The following direct subclasses are provided for convenience:
@@ -99,6 +88,74 @@ import org.apache.juneau.serializer.*;
*/
public class JsonSerializer extends WriterSerializer {
+ //-------------------------------------------------------------------------------------------------------------------
+ // Configurable properties
+ //-------------------------------------------------------------------------------------------------------------------
+
+ private static final String PREFIX = "JsonSerializer.";
+
+ /**
+ * <b>Configuration property:</b> Simple JSON mode.
+ *
+ * <ul>
+ * <li><b>Name:</b> <js>"JsonSerializer.simpleMode"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * <li><b>Session-overridable:</b> <jk>true</jk>
+ * </ul>
+ *
+ * <p>
+ * If <jk>true</jk>, JSON attribute names will only be quoted when necessary.
+ * Otherwise, they are always quoted.
+ */
+ public static final String JSON_simpleMode = PREFIX + "simpleMode";
+
+ /**
+ * <b>Configuration property:</b> Prefix solidus <js>'/'</js> characters with escapes.
+ *
+ * <ul>
+ * <li><b>Name:</b> <js>"JsonSerializer.escapeSolidus"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * <li><b>Session-overridable:</b> <jk>true</jk>
+ * </ul>
+ *
+ * <p>
+ * If <jk>true</jk>, solidus (e.g. slash) characters should be escaped.
+ * The JSON specification allows for either format.
+ * However, if you're embedding JSON in an HTML script tag, this setting prevents confusion when trying to serialize
+ * <xt><\/script></xt>.
+ */
+ public static final String JSON_escapeSolidus = PREFIX + "escapeSolidus";
+
+ /**
+ * <b>Configuration property:</b> Add <js>"_type"</js> properties when needed.
+ *
+ * <ul>
+ * <li><b>Name:</b> <js>"JsonSerializer.addBeanTypeProperties"</js>
+ * <li><b>Data type:</b> <code>Boolean</code>
+ * <li><b>Default:</b> <jk>false</jk>
+ * <li><b>Session-overridable:</b> <jk>true</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.
+ * For example, when serializing a {@code Map<String,Object>} field, where the bean class cannot be determined from
+ * the value type.
+ *
+ * <p>
+ * When present, this value overrides the {@link #SERIALIZER_addBeanTypeProperties} setting and is
+ * provided to customize the behavior of specific serializers in a {@link SerializerGroup}.
+ */
+ public static final String JSON_addBeanTypeProperties = PREFIX + "addBeanTypeProperties";
+
+
+ //-------------------------------------------------------------------------------------------------------------------
+ // Predefined instances
+ //-------------------------------------------------------------------------------------------------------------------
+
/** Default serializer, all default settings.*/
public static final JsonSerializer DEFAULT = new JsonSerializer(PropertyStore.create());
@@ -118,6 +175,10 @@ public class JsonSerializer extends WriterSerializer {
public static final JsonSerializer DEFAULT_LAX_READABLE_SAFE = new SimpleReadableSafe(PropertyStore.create());
+ //-------------------------------------------------------------------------------------------------------------------
+ // Predefined subclasses
+ //-------------------------------------------------------------------------------------------------------------------
+
/** Default serializer, with whitespace. */
public static class Readable extends JsonSerializer {
@@ -194,6 +255,10 @@ public class JsonSerializer extends WriterSerializer {
}
+ //-------------------------------------------------------------------------------------------------------------------
+ // Instance
+ //-------------------------------------------------------------------------------------------------------------------
+
final JsonSerializerContext ctx;
private volatile JsonSchemaSerializer schemaSerializer;
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d22f1b26/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializerBuilder.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializerBuilder.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializerBuilder.java
index 14393cc..e411b91 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializerBuilder.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializerBuilder.java
@@ -12,7 +12,7 @@
// ***************************************************************************************************************************
package org.apache.juneau.json;
-import static org.apache.juneau.json.JsonSerializerContext.*;
+import static org.apache.juneau.json.JsonSerializer.*;
import java.util.*;
@@ -72,7 +72,7 @@ public class JsonSerializerBuilder extends SerializerBuilder {
*
* @param value The new value for this property.
* @return This object (for method chaining).
- * @see JsonSerializerContext#JSON_simpleMode
+ * @see JsonSerializer#JSON_simpleMode
*/
public JsonSerializerBuilder simple(boolean value) {
return property(JSON_simpleMode, value);
@@ -110,7 +110,7 @@ public class JsonSerializerBuilder extends SerializerBuilder {
*
* @param value The new value for this property.
* @return This object (for method chaining).
- * @see JsonSerializerContext#JSON_escapeSolidus
+ * @see JsonSerializer#JSON_escapeSolidus
*/
public JsonSerializerBuilder escapeSolidus(boolean value) {
return property(JSON_escapeSolidus, value);
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d22f1b26/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializerContext.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializerContext.java b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializerContext.java
index 0284aee..599e5cc 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializerContext.java
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/JsonSerializerContext.java
@@ -12,93 +12,16 @@
// ***************************************************************************************************************************
package org.apache.juneau.json;
+import static org.apache.juneau.json.JsonSerializer.*;
+
import org.apache.juneau.*;
import org.apache.juneau.serializer.*;
/**
- * Configurable properties on the {@link JsonSerializer} class.
- *
- * <p>
- * Context properties are set by calling {@link PropertyStore#setProperty(String, Object)} on the property store
- * passed into the constructor.
- *
- * <p>
- * See {@link PropertyStore} for more information about context properties.
- *
- * <h6 class='topic'>Inherited configurable properties</h6>
- * <ul class='doctree'>
- * <li class='jc'>
- * <a class="doclink" href="../BeanContext.html#ConfigProperties">BeanContext</a>
- * - Properties associated with handling beans on serializers and parsers.
- * <ul>
- * <li class='jc'>
- * <a class="doclink" href="../serializer/SerializerContext.html#ConfigProperties">SerializerContext</a>
- * - Configurable properties common to all serializers.
- * </ul>
- * </li>
- * </ul>
+ * Contains a snapshot-in-time read-only copy of the settings on the {@link JsonSerializer} class.
*/
public final class JsonSerializerContext extends SerializerContext {
- static final String PREFIX = "JsonSerializer.";
-
- /**
- * <b>Configuration property:</b> Simple JSON mode.
- *
- * <ul>
- * <li><b>Name:</b> <js>"JsonSerializer.simpleMode"</js>
- * <li><b>Data type:</b> <code>Boolean</code>
- * <li><b>Default:</b> <jk>false</jk>
- * <li><b>Session-overridable:</b> <jk>true</jk>
- * </ul>
- *
- * <p>
- * If <jk>true</jk>, JSON attribute names will only be quoted when necessary.
- * Otherwise, they are always quoted.
- */
- public static final String JSON_simpleMode = PREFIX + "simpleMode";
-
- /**
- * <b>Configuration property:</b> Prefix solidus <js>'/'</js> characters with escapes.
- *
- * <ul>
- * <li><b>Name:</b> <js>"JsonSerializer.escapeSolidus"</js>
- * <li><b>Data type:</b> <code>Boolean</code>
- * <li><b>Default:</b> <jk>false</jk>
- * <li><b>Session-overridable:</b> <jk>true</jk>
- * </ul>
- *
- * <p>
- * If <jk>true</jk>, solidus (e.g. slash) characters should be escaped.
- * The JSON specification allows for either format.
- * However, if you're embedding JSON in an HTML script tag, this setting prevents confusion when trying to serialize
- * <xt><\/script></xt>.
- */
- public static final String JSON_escapeSolidus = PREFIX + "escapeSolidus";
-
- /**
- * <b>Configuration property:</b> Add <js>"_type"</js> properties when needed.
- *
- * <ul>
- * <li><b>Name:</b> <js>"JsonSerializer.addBeanTypeProperties"</js>
- * <li><b>Data type:</b> <code>Boolean</code>
- * <li><b>Default:</b> <jk>false</jk>
- * <li><b>Session-overridable:</b> <jk>true</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.
- * For example, when serializing a {@code Map<String,Object>} field, where the bean class cannot be determined from
- * the value type.
- *
- * <p>
- * When present, this value overrides the {@link SerializerContext#SERIALIZER_addBeanTypeProperties} setting and is
- * provided to customize the behavior of specific serializers in a {@link SerializerGroup}.
- */
- public static final String JSON_addBeanTypeProperties = PREFIX + "addBeanTypeProperties";
-
final boolean
simpleMode,
escapeSolidus,
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d22f1b26/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 6762136..628c1f0 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
@@ -12,7 +12,7 @@
// ***************************************************************************************************************************
package org.apache.juneau.json;
-import static org.apache.juneau.json.JsonSerializerContext.*;
+import static org.apache.juneau.json.JsonSerializer.*;
import java.util.*;
@@ -238,9 +238,9 @@ public class JsonSerializerSession extends WriterSerializerSession {
/**
- * Returns the {@link JsonSerializerContext#JSON_addBeanTypeProperties} setting value for this session.
+ * Returns the {@link JsonSerializer#JSON_addBeanTypeProperties} setting value for this session.
*
- * @return The {@link JsonSerializerContext#JSON_addBeanTypeProperties} setting value for this session.
+ * @return The {@link JsonSerializer#JSON_addBeanTypeProperties} setting value for this session.
*/
@Override /* SerializerSession */
protected final boolean isAddBeanTypeProperties() {
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/d22f1b26/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/package.html
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/package.html b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/package.html
index 3c3e845..9e1598a 100644
--- a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/package.html
+++ b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/json/package.html
@@ -647,12 +647,12 @@
The JSON serializer is designed to be used against POJO tree structures.
<br>It expects that there not be loops in the POJO model (e.g. children with references to parents, etc...).
<br>If you try to serialize models with loops, you will usually cause a <code>StackOverflowError</code> to
- be thrown (if {@link org.apache.juneau.serializer.SerializerContext#SERIALIZER_maxDepth} is not reached
+ be thrown (if {@link org.apache.juneau.serializer.Serializer#SERIALIZER_maxDepth} is not reached
first).
</p>
<p>
If you still want to use the JSON serializer on such models, Juneau provides the
- {@link org.apache.juneau.serializer.SerializerContext#SERIALIZER_detectRecursions} setting.
+ {@link org.apache.juneau.serializer.Serializer#SERIALIZER_detectRecursions} setting.
<br>It tells the serializer to look for instances of an object in the current branch of the tree and skip
serialization when a duplicate is encountered.
</p>