This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push:
new 46baa7b Context API refactoring.
46baa7b is described below
commit 46baa7b2da3c435d8925d1fae26f83cf217173c5
Author: JamesBognar <[email protected]>
AuthorDate: Mon Sep 27 11:44:19 2021 -0400
Context API refactoring.
---
.../org/apache/juneau/html/HtmlParserBuilder.java | 21 ---
.../org/apache/juneau/xml/XmlDocSerializer.java | 2 +-
.../main/java/org/apache/juneau/xml/XmlParser.java | 194 ++++-----------------
.../org/apache/juneau/xml/XmlParserBuilder.java | 111 ++++--------
.../org/apache/juneau/xml/XmlParserSession.java | 10 +-
.../apache/juneau/xml/annotation/XmlConfig.java | 12 +-
.../juneau/xml/annotation/XmlConfigAnnotation.java | 42 +++--
7 files changed, 111 insertions(+), 281 deletions(-)
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserBuilder.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserBuilder.java
index c87f81c..9351378 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserBuilder.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserBuilder.java
@@ -17,9 +17,6 @@ import java.lang.reflect.*;
import java.nio.charset.*;
import java.util.*;
-import javax.xml.stream.*;
-import javax.xml.stream.util.*;
-
import org.apache.juneau.*;
import org.apache.juneau.http.header.*;
import org.apache.juneau.internal.*;
@@ -561,12 +558,6 @@ public class HtmlParserBuilder extends XmlParserBuilder {
}
@Override /* GENERATED - XmlParserBuilder */
- public HtmlParserBuilder eventAllocator(XMLEventAllocator value) {
- super.eventAllocator(value);
- return this;
- }
-
- @Override /* GENERATED - XmlParserBuilder */
public HtmlParserBuilder preserveRootElement() {
super.preserveRootElement();
return this;
@@ -579,24 +570,12 @@ public class HtmlParserBuilder extends XmlParserBuilder {
}
@Override /* GENERATED - XmlParserBuilder */
- public HtmlParserBuilder reporter(XMLReporter value) {
- super.reporter(value);
- return this;
- }
-
- @Override /* GENERATED - XmlParserBuilder */
public HtmlParserBuilder resolver(Class<? extends
javax.xml.stream.XMLResolver> value) {
super.resolver(value);
return this;
}
@Override /* GENERATED - XmlParserBuilder */
- public HtmlParserBuilder resolver(XMLResolver value) {
- super.resolver(value);
- return this;
- }
-
- @Override /* GENERATED - XmlParserBuilder */
public HtmlParserBuilder validating() {
super.validating();
return this;
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlDocSerializer.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlDocSerializer.java
index 6cd4293..6ea3530 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlDocSerializer.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlDocSerializer.java
@@ -33,7 +33,7 @@ import org.apache.juneau.serializer.*;
public class XmlDocSerializer extends XmlSerializer {
//-------------------------------------------------------------------------------------------------------------------
- // Predefined subclasses
+ // Static subclasses
//-------------------------------------------------------------------------------------------------------------------
/** Default serializer without namespaces. */
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParser.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParser.java
index be262ab..45f5ca5 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParser.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParser.java
@@ -12,6 +12,9 @@
//
***************************************************************************************************************************
package org.apache.juneau.xml;
+import static java.util.Optional.*;
+import static org.apache.juneau.internal.ExceptionUtils.*;
+
import java.util.*;
import java.util.concurrent.*;
@@ -39,160 +42,26 @@ import org.apache.juneau.parser.*;
public class XmlParser extends ReaderParser implements XmlMetaProvider {
//-------------------------------------------------------------------------------------------------------------------
- // Configurable properties
-
//-------------------------------------------------------------------------------------------------------------------
-
- static final String PREFIX = "XmlParser";
-
- /**
- * Configuration property: XML event allocator.
- *
- * <p>
- * Associates an {@link XMLEventAllocator} with this parser.
- *
- * <h5 class='section'>Property:</h5>
- * <ul class='spaced-list'>
- * <li><b>ID:</b> {@link
org.apache.juneau.xml.XmlParser#XML_eventAllocator XML_eventAllocator}
- * <li><b>Name:</b> <js>"XmlParser.eventAllocator.c"</js>
- * <li><b>Data type:</b> <code>Class<{@link
javax.xml.stream.util.XMLEventAllocator}></code>
- * <li><b>Default:</b> <jk>null</jk>
- * <li><b>Session property:</b> <jk>false</jk>
- * <li><b>Annotations:</b>
- * <ul>
- * <li class='ja'>{@link
org.apache.juneau.xml.annotation.XmlConfig#eventAllocator()}
- * </ul>
- * <li><b>Methods:</b>
- * <ul>
- * <li class='jm'>{@link
org.apache.juneau.xml.XmlParserBuilder#eventAllocator(XMLEventAllocator)}
- * </ul>
- * </ul>
- */
- public static final String XML_eventAllocator = PREFIX +
".eventAllocator.c";
-
- /**
- * Configuration property: Preserve root element during generalized
parsing.
- *
- * <p>
- * When enabled, when parsing into a generic {@link OMap}, the map will
contain a single entry whose key
- * is the root element name.
- *
- * <h5 class='section'>Property:</h5>
- * <ul class='spaced-list'>
- * <li><b>ID:</b> {@link
org.apache.juneau.xml.XmlParser#XML_preserveRootElement XML_preserveRootElement}
- * <li><b>Name:</b> <js>"XmlParser.preserveRootElement.b"</js>
- * <li><b>Data type:</b> <jk>boolean</jk>
- * <li><b>System property:</b>
<c>XmlParser.preserveRootElement</c>
- * <li><b>Environment variable:</b>
<c>XMLPARSER_PRESERVEROOTELEMENT</c>
- * <li><b>Default:</b> <jk>false</jk>
- * <li><b>Session property:</b> <jk>false</jk>
- * <li><b>Annotations:</b>
- * <ul>
- * <li class='ja'>{@link
org.apache.juneau.xml.annotation.XmlConfig#preserveRootElement()}
- * </ul>
- * <li><b>Methods:</b>
- * <ul>
- * <li class='jm'>{@link
org.apache.juneau.xml.XmlParserBuilder#preserveRootElement()}
- * </ul>
- * </ul>
- */
- public static final String XML_preserveRootElement = PREFIX +
".preserveRootElement.b";
-
- /**
- * Configuration property: XML reporter.
- *
- * <p>
- * Associates an {@link XMLReporter} with this parser.
- *
- * <h5 class='section'>Property:</h5>
- * <ul class='spaced-list'>
- * <li><b>ID:</b> {@link
org.apache.juneau.xml.XmlParser#XML_reporter XML_reporter}
- * <li><b>Name:</b> <js>"XmlParser.reporter.c"</js>
- * <li><b>Data type:</b> <code>Class<{@link
javax.xml.stream.XMLReporter}></code>
- * <li><b>Default:</b> <jk>null</jk>
- * <li><b>Session property:</b> <jk>false</jk>
- * <li><b>Annotations:</b>
- * <ul>
- * <li class='ja'>{@link
org.apache.juneau.xml.annotation.XmlConfig#reporter()}
- * </ul>
- * <li><b>Methods:</b>
- * <ul>
- * <li class='jm'>{@link
org.apache.juneau.xml.XmlParserBuilder#reporter(XMLReporter)}
- * </ul>
- * </ul>
- */
- public static final String XML_reporter = PREFIX + ".reporter.c";
-
- /**
- * Configuration property: XML resolver.
- *
- * <p>
- * Associates an {@link XMLResolver} with this parser.
- *
- * <h5 class='section'>Property:</h5>
- * <ul class='spaced-list'>
- * <li><b>ID:</b> {@link
org.apache.juneau.xml.XmlParser#XML_resolver XML_resolver}
- * <li><b>Name:</b> <js>"XmlParser.resolver.c"</js>
- * <li><b>Data type:</b> <code>Class<{@link
javax.xml.stream.XMLResolver}></code>
- * <li><b>Default:</b> <jk>null</jk>
- * <li><b>Session property:</b> <jk>false</jk>
- * <li><b>Annotations:</b>
- * <ul>
- * <li class='ja'>{@link
org.apache.juneau.xml.annotation.XmlConfig#resolver()}
- * </ul>
- * <li><b>Methods:</b>
- * <ul>
- * <li class='jm'>{@link
org.apache.juneau.xml.XmlParserBuilder#resolver(XMLResolver)}
- * </ul>
- * </ul>
- */
- public static final String XML_resolver = PREFIX + ".resolver.c";
-
- /**
- * Configuration property: Enable validation.
- *
- * <p>
- * If <jk>true</jk>, XML document will be validated.
- *
- * <h5 class='section'>Property:</h5>
- * <ul class='spaced-list'>
- * <li><b>ID:</b> {@link
org.apache.juneau.xml.XmlParser#XML_validating XML_validating}
- * <li><b>Name:</b> <js>"XmlParser.validating.b"</js>
- * <li><b>Data type:</b> <jk>boolean</jk>
- * <li><b>System property:</b> <c>XmlParser.validating</c>
- * <li><b>Environment variable:</b> <c>XMLPARSER_VALIDATING</c>
- * <li><b>Default:</b> <jk>false</jk>
- * <li><b>Session property:</b> <jk>false</jk>
- * <li><b>Annotations:</b>
- * <ul>
- * <li class='ja'>{@link
org.apache.juneau.xml.annotation.XmlConfig#validating()}
- * </ul>
- * <li><b>Methods:</b>
- * <ul>
- * <li class='jm'>{@link
org.apache.juneau.xml.XmlParserBuilder#validating()}
- * </ul>
- * </ul>
- */
- public static final String XML_validating = PREFIX + ".validating.b";
-
-
-
//-------------------------------------------------------------------------------------------------------------------
- // Predefined instances
+ // Static
//-------------------------------------------------------------------------------------------------------------------
/** Default parser, all default settings.*/
public static final XmlParser DEFAULT = new XmlParser(create());
-
//-------------------------------------------------------------------------------------------------------------------
// Instance
//-------------------------------------------------------------------------------------------------------------------
- private final boolean
+ final boolean
validating,
preserveRootElement;
- private final XMLReporter reporter;
- private final XMLResolver resolver;
- private final XMLEventAllocator eventAllocator;
+ final Class<? extends XMLEventAllocator> eventAllocator;
+ final Class<? extends XMLReporter> reporter;
+ final Class<? extends XMLResolver> resolver;
+
+ private final XMLReporter reporterImpl;
+ private final XMLResolver resolverImpl;
+ private final XMLEventAllocator eventAllocatorImpl;
private final Map<ClassMeta<?>,XmlClassMeta> xmlClassMetas = new
ConcurrentHashMap<>();
private final Map<BeanMeta<?>,XmlBeanMeta> xmlBeanMetas = new
ConcurrentHashMap<>();
private final Map<BeanPropertyMeta,XmlBeanPropertyMeta>
xmlBeanPropertyMetas = new ConcurrentHashMap<>();
@@ -205,12 +74,15 @@ public class XmlParser extends ReaderParser implements
XmlMetaProvider {
*/
protected XmlParser(XmlParserBuilder builder) {
super(builder);
- ContextProperties cp = getContextProperties();
- validating = cp.getBoolean(XML_validating).orElse(false);
- preserveRootElement =
cp.getBoolean(XML_preserveRootElement).orElse(false);
- reporter = cp.getInstance(XML_reporter,
XMLReporter.class).orElse(null);
- resolver = cp.getInstance(XML_resolver,
XMLResolver.class).orElse(null);
- eventAllocator = cp.getInstance(XML_eventAllocator,
XMLEventAllocator.class).orElse(null);
+ validating = builder.validating;
+ preserveRootElement = builder.preserveRootElement;
+ reporter = builder.reporter;
+ resolver = builder.resolver;
+ eventAllocator = builder.eventAllocator;
+
+ reporterImpl = ofNullable(reporter).map(x ->
newInstance(x)).orElse(null);
+ resolverImpl = ofNullable(resolver).map(x ->
newInstance(x)).orElse(null);
+ eventAllocatorImpl = ofNullable(eventAllocator).map(x ->
newInstance(x)).orElse(null);
}
@Override /* Context */
@@ -286,18 +158,18 @@ public class XmlParser extends ReaderParser implements
XmlMetaProvider {
/**
* XML event allocator.
*
- * @see #XML_eventAllocator
+ * @see XmlParserBuilder#eventAllocator(Class)
* @return
* The {@link XMLEventAllocator} associated with this parser, or
<jk>null</jk> if there isn't one.
*/
protected final XMLEventAllocator getEventAllocator() {
- return eventAllocator;
+ return eventAllocatorImpl;
}
/**
* Preserve root element during generalized parsing.
*
- * @see #XML_preserveRootElement
+ * @see XmlParserBuilder#preserveRootElement()
* @return
* <jk>true</jk> if when parsing into a generic {@link OMap}, the
map will contain a single entry whose key
* is the root element name.
@@ -309,29 +181,29 @@ public class XmlParser extends ReaderParser implements
XmlMetaProvider {
/**
* XML reporter.
*
- * @see #XML_reporter
+ * @see XmlParserBuilder#reporter(Class)
* @return
* The {@link XMLReporter} associated with this parser, or
<jk>null</jk> if there isn't one.
*/
protected final XMLReporter getReporter() {
- return reporter;
+ return reporterImpl;
}
/**
* XML resolver.
*
- * @see #XML_resolver
+ * @see XmlParserBuilder#resolver(Class)
* @return
* The {@link XMLResolver} associated with this parser, or
<jk>null</jk> if there isn't one.
*/
protected final XMLResolver getResolver() {
- return resolver;
+ return resolverImpl;
}
/**
* Enable validation.
*
- * @see #XML_validating
+ * @see XmlParserBuilder#validating()
* @return
* <jk>true</jk> if XML document will be validated.
*/
@@ -343,6 +215,14 @@ public class XmlParser extends ReaderParser implements
XmlMetaProvider {
// Other methods
//-----------------------------------------------------------------------------------------------------------------
+ private <T> T newInstance(Class<T> c) {
+ try {
+ return c.newInstance();
+ } catch (Exception e) {
+ throw runtimeException(e);
+ }
+ }
+
@Override /* Context */
public OMap toMap() {
return super.toMap()
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserBuilder.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserBuilder.java
index a135138..1f1c0c0 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserBuilder.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserBuilder.java
@@ -12,8 +12,6 @@
//
***************************************************************************************************************************
package org.apache.juneau.xml;
-import static org.apache.juneau.xml.XmlParser.*;
-
import java.lang.annotation.*;
import java.lang.reflect.*;
import java.nio.charset.*;
@@ -35,6 +33,11 @@ import org.apache.juneau.parser.*;
@FluentSetters
public class XmlParserBuilder extends ReaderParserBuilder {
+ boolean preserveRootElement, validating;
+ Class<? extends XMLEventAllocator> eventAllocator;
+ Class<? extends XMLReporter> reporter;
+ Class<? extends XMLResolver> resolver;
+
/**
* Constructor, default settings.
*/
@@ -82,34 +85,13 @@ public class XmlParserBuilder extends ReaderParserBuilder {
* <p>
* Associates an {@link XMLEventAllocator} with this parser.
*
- * <ul class='seealso'>
- * <li class='jf'>{@link XmlParser#XML_eventAllocator}
- * </ul>
- *
- * @param value The new value for this property.
- * @return This object (for method chaining).
- */
- @FluentSetter
- public XmlParserBuilder eventAllocator(XMLEventAllocator value) {
- return set(XML_eventAllocator, value);
- }
-
- /**
- * XML event allocator.
- *
- * <p>
- * Associates an {@link XMLEventAllocator} with this parser.
- *
- * <ul class='seealso'>
- * <li class='jf'>{@link XmlParser#XML_eventAllocator}
- * </ul>
- *
* @param value The new value for this property.
* @return This object (for method chaining).
*/
@FluentSetter
public XmlParserBuilder eventAllocator(Class<? extends
XMLEventAllocator> value) {
- return set(XML_eventAllocator, value);
+ eventAllocator = value;
+ return this;
}
/**
@@ -141,38 +123,23 @@ public class XmlParserBuilder extends ReaderParserBuilder
{
* OMap <jv>myMap2</jv> = <jv>parser2</jv>.parse(<jv>xml</jv>,
OMap.<jk>class)</jk>;
* </p>
*
- * <ul class='seealso'>
- * <li class='jf'>{@link XmlParser#XML_preserveRootElement}
- * </ul>
- *
* @return This object (for method chaining).
*/
@FluentSetter
public XmlParserBuilder preserveRootElement() {
- return set(XML_preserveRootElement);
+ return preserveRootElement(true);
}
/**
- * XML reporter.
+ * Same as {@link #preserveRootElement()} but allows you to explicitly
specify the value.
*
- * <p>
- * Associates an {@link XMLReporter} with this parser.
- *
- * <ul class='notes'>
- * <li>
- * Reporters are not copied to new parsers during a clone.
- * </ul>
- *
- * <ul class='seealso'>
- * <li class='jf'>{@link XmlParser#XML_reporter}
- * </ul>
- *
- * @param value The new value for this property.
- * @return This object (for method chaining).
+ * @param value The value for this setting.
+ * @return This object.
*/
@FluentSetter
- public XmlParserBuilder reporter(XMLReporter value) {
- return set(XML_reporter, value);
+ public XmlParserBuilder preserveRootElement(boolean value) {
+ preserveRootElement = value;
+ return this;
}
/**
@@ -181,34 +148,13 @@ public class XmlParserBuilder extends ReaderParserBuilder
{
* <p>
* Associates an {@link XMLReporter} with this parser.
*
- * <ul class='seealso'>
- * <li class='jf'>{@link XmlParser#XML_reporter}
- * </ul>
- *
* @param value The new value for this property.
* @return This object (for method chaining).
*/
@FluentSetter
public XmlParserBuilder reporter(Class<? extends XMLReporter> value) {
- return set(XML_reporter, value);
- }
-
- /**
- * XML resolver.
- *
- * <p>
- * Associates an {@link XMLResolver} with this parser.
- *
- * <ul class='seealso'>
- * <li class='jf'>{@link XmlParser#XML_resolver}
- * </ul>
- *
- * @param value The new value for this property.
- * @return This object (for method chaining).
- */
- @FluentSetter
- public XmlParserBuilder resolver(XMLResolver value) {
- return set(XML_resolver, value);
+ reporter = value;
+ return this;
}
/**
@@ -217,16 +163,13 @@ public class XmlParserBuilder extends ReaderParserBuilder
{
* <p>
* Associates an {@link XMLResolver} with this parser.
*
- * <ul class='seealso'>
- * <li class='jf'>{@link XmlParser#XML_resolver}
- * </ul>
- *
* @param value The new value for this property.
* @return This object (for method chaining).
*/
@FluentSetter
public XmlParserBuilder resolver(Class<? extends XMLResolver> value) {
- return set(XML_resolver, value);
+ resolver = value;
+ return this;
}
/**
@@ -238,15 +181,23 @@ public class XmlParserBuilder extends ReaderParserBuilder
{
* <p>
* See {@link XMLInputFactory#IS_VALIDATING} for more info.
*
- * <ul class='seealso'>
- * <li class='jf'>{@link XmlParser#XML_validating}
- * </ul>
- *
* @return This object (for method chaining).
*/
@FluentSetter
public XmlParserBuilder validating() {
- return set(XML_validating);
+ return validating(true);
+ }
+
+ /**
+ * Same as {@link #validating()} but allows you to explicitly specify
the value.
+ *
+ * @param value The value for this setting.
+ * @return This object.
+ */
+ @FluentSetter
+ public XmlParserBuilder validating(boolean value) {
+ validating = value;
+ return this;
}
// <FluentSetters>
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserSession.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserSession.java
index 3189ea8..887661b 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserSession.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/XmlParserSession.java
@@ -729,7 +729,7 @@ public class XmlParserSession extends ReaderParserSession {
/**
* Configuration property: XML event allocator.
*
- * @see XmlParser#XML_eventAllocator
+ * @see XmlParserBuilder#eventAllocator(Class)
* @return
* The {@link XMLEventAllocator} associated with this parser, or
<jk>null</jk> if there isn't one.
*/
@@ -740,7 +740,7 @@ public class XmlParserSession extends ReaderParserSession {
/**
* Configuration property: Preserve root element during generalized
parsing.
*
- * @see XmlParser#XML_preserveRootElement
+ * @see XmlParserBuilder#preserveRootElement()
* @return
* <jk>true</jk> if when parsing into a generic {@link OMap}, the
map will contain a single entry whose key
* is the root element name.
@@ -752,7 +752,7 @@ public class XmlParserSession extends ReaderParserSession {
/**
* Configuration property: XML reporter.
*
- * @see XmlParser#XML_reporter
+ * @see XmlParserBuilder#reporter(Class)
* @return
* The {@link XMLReporter} associated with this parser, or
<jk>null</jk> if there isn't one.
*/
@@ -763,7 +763,7 @@ public class XmlParserSession extends ReaderParserSession {
/**
* Configuration property: XML resolver.
*
- * @see XmlParser#XML_resolver
+ * @see XmlParserBuilder#resolver(Class)
* @return
* The {@link XMLResolver} associated with this parser, or
<jk>null</jk> if there isn't one.
*/
@@ -774,7 +774,7 @@ public class XmlParserSession extends ReaderParserSession {
/**
* Configuration property: Enable validation.
*
- * @see XmlParser#XML_validating
+ * @see XmlParserBuilder#validating()
* @return
* <jk>true</jk> if XML document will be validated.
*/
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/annotation/XmlConfig.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/annotation/XmlConfig.java
index 8a05546..fe46fdf 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/annotation/XmlConfig.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/annotation/XmlConfig.java
@@ -35,7 +35,7 @@ import org.apache.juneau.xml.*;
@Target({TYPE,METHOD})
@Retention(RUNTIME)
@Inherited
-@ContextApply(XmlConfigAnnotation.Apply.class)
+@ContextApply({XmlConfigAnnotation.SerializerApply.class,XmlConfigAnnotation.ParserApply.class})
public @interface XmlConfig {
/**
@@ -61,7 +61,7 @@ public @interface XmlConfig {
* Associates an {@link XMLEventAllocator} with this parser.
*
* <ul class='seealso'>
- * <li class='jf'>{@link XmlParser#XML_eventAllocator}
+ * <li class='jm'>{@link XmlParserBuilder#eventAllocator(Class)}
* </ul>
*/
Class<? extends XMLEventAllocator> eventAllocator() default
XmlEventAllocator.Null.class;
@@ -85,7 +85,7 @@ public @interface XmlConfig {
* </ul>
*
* <ul class='seealso'>
- * <li class='jf'>{@link XmlParser#XML_preserveRootElement}
+ * <li class='jm'>{@link XmlParserBuilder#preserveRootElement()}
* </ul>
*/
String preserveRootElement() default "";
@@ -102,7 +102,7 @@ public @interface XmlConfig {
* </ul>
*
* <ul class='seealso'>
- * <li class='jf'>{@link XmlParser#XML_reporter}
+ * <li class='jm'>{@link XmlParserBuilder#reporter(Class)}
* </ul>
*/
Class<? extends XMLReporter> reporter() default XmlReporter.Null.class;
@@ -114,7 +114,7 @@ public @interface XmlConfig {
* Associates an {@link XMLResolver} with this parser.
*
* <ul class='seealso'>
- * <li class='jf'>{@link XmlParser#XML_resolver}
+ * <li class='jm'>{@link XmlParserBuilder#resolver(Class)}
* </ul>
*/
Class<? extends XMLResolver> resolver() default XmlResolver.Null.class;
@@ -140,7 +140,7 @@ public @interface XmlConfig {
* </ul>
*
* <ul class='seealso'>
- * <li class='jf'>{@link XmlParser#XML_validating}
+ * <li class='jm'>{@link XmlParserBuilder#validating()}
* </ul>
*/
String validating() default "";
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/annotation/XmlConfigAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/annotation/XmlConfigAnnotation.java
index fea6334..a1c90df 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/annotation/XmlConfigAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/xml/annotation/XmlConfigAnnotation.java
@@ -12,7 +12,6 @@
//
***************************************************************************************************************************
package org.apache.juneau.xml.annotation;
-import static org.apache.juneau.xml.XmlParser.*;
import static org.apache.juneau.xml.XmlSerializer.*;
import org.apache.juneau.*;
@@ -26,21 +25,21 @@ import org.apache.juneau.xml.*;
public class XmlConfigAnnotation {
/**
- * Applies {@link XmlConfig} annotations to a {@link
ContextPropertiesBuilder}.
+ * Applies {@link XmlConfig} annotations to a {@link
XmlSerializerBuilder}.
*/
- public static class Apply extends
AnnotationApplier<XmlConfig,ContextPropertiesBuilder> {
+ public static class SerializerApply extends
AnnotationApplier<XmlConfig,XmlSerializerBuilder> {
/**
* Constructor.
*
* @param vr The resolver for resolving values in annotations.
*/
- public Apply(VarResolverSession vr) {
- super(XmlConfig.class, ContextPropertiesBuilder.class,
vr);
+ public SerializerApply(VarResolverSession vr) {
+ super(XmlConfig.class, XmlSerializerBuilder.class, vr);
}
@Override
- public void apply(AnnotationInfo<XmlConfig> ai,
ContextPropertiesBuilder b) {
+ public void apply(AnnotationInfo<XmlConfig> ai,
XmlSerializerBuilder b) {
XmlConfig a = ai.getAnnotation();
bool(a.addBeanTypes()).ifPresent(x ->
b.set(XML_addBeanTypes, x));
@@ -49,11 +48,32 @@ public class XmlConfigAnnotation {
string(a.defaultNamespace()).ifPresent(x ->
b.set(XML_defaultNamespace, x));
bool(a.enableNamespaces()).ifPresent(x ->
b.set(XML_enableNamespaces, x));
b.setIf(a.namespaces().length > 0, XML_namespaces,
Namespace.createArray(stringList(a.namespaces())));
- type(a.eventAllocator()).ifPresent(x ->
b.set(XML_eventAllocator, x));
- bool(a.preserveRootElement()).ifPresent(x ->
b.set(XML_preserveRootElement, x));
- type(a.reporter()).ifPresent(x -> b.set(XML_reporter,
x));
- type(a.resolver()).ifPresent(x -> b.set(XML_resolver,
x));
- bool(a.validating()).ifPresent(x ->
b.set(XML_validating, x));
+ }
+ }
+
+ /**
+ * Applies {@link XmlConfig} annotations to a {@link XmlParserBuilder}.
+ */
+ public static class ParserApply extends
AnnotationApplier<XmlConfig,XmlParserBuilder> {
+
+ /**
+ * Constructor.
+ *
+ * @param vr The resolver for resolving values in annotations.
+ */
+ public ParserApply(VarResolverSession vr) {
+ super(XmlConfig.class, XmlParserBuilder.class, vr);
+ }
+
+ @Override
+ public void apply(AnnotationInfo<XmlConfig> ai,
XmlParserBuilder b) {
+ XmlConfig a = ai.getAnnotation();
+
+ type(a.eventAllocator()).ifPresent(x ->
b.eventAllocator(x));
+ bool(a.preserveRootElement()).ifPresent(x ->
b.preserveRootElement(x));
+ type(a.reporter()).ifPresent(x -> b.reporter(x));
+ type(a.resolver()).ifPresent(x -> b.resolver(x));
+ bool(a.validating()).ifPresent(x -> b.validating(x));
}
}
}
\ No newline at end of file