http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/68dffad1/juneau-core/src/main/java/org/apache/juneau/xml/XmlParser.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlParser.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlParser.java index 0e04e3f..f352c47 100644 --- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlParser.java +++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlParser.java @@ -15,14 +15,15 @@ package org.apache.juneau.xml; import static javax.xml.stream.XMLStreamConstants.*; import static org.apache.juneau.internal.StringUtils.*; import static org.apache.juneau.xml.annotation.XmlFormat.*; +import static org.apache.juneau.xml.XmlParserContext.*; import java.lang.reflect.*; import java.util.*; import javax.xml.stream.*; +import javax.xml.stream.util.*; import org.apache.juneau.*; -import org.apache.juneau.MediaType; import org.apache.juneau.annotation.*; import org.apache.juneau.parser.*; import org.apache.juneau.transform.*; @@ -499,7 +500,7 @@ public class XmlParser extends ReaderParser { //-------------------------------------------------------------------------------- - // Overridden methods + // Entry point methods //-------------------------------------------------------------------------------- @Override /* Parser */ @@ -533,49 +534,566 @@ public class XmlParser extends ReaderParser { return doParseArgs(s, s.getXmlStreamReader(), argTypes); } + + //-------------------------------------------------------------------------------- + // Properties + //-------------------------------------------------------------------------------- + + /** + * <b>Configuration property:</b> Enable validation. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlParser.validating"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * <li><b>Session-overridable:</b> <jk>true</jk> + * </ul> + * <p> + * If <jk>true</jk>, XML document will be validated. + * See {@link XMLInputFactory#IS_VALIDATING} for more info. + * <p> + * If <jk>true</jk>, string values will be trimmed of whitespace using {@link String#trim()} before being added to the POJO. + * <p> + * <h5 class='section'>Notes:</h5> + * <ul> + * <li>This is equivalent to calling <code>setProperty(<jsf>XML_validating</jsf>, value)</code>. + * </ul> + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see XmlParserContext#XML_validating + */ + public XmlParser setValidating(boolean value) throws LockedException { + return setProperty(XML_validating, value); + } + + /** + * <b>Configuration property:</b> XML reporter. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlParser.reporter"</js> + * <li><b>Data type:</b> {@link XMLReporter} + * <li><b>Default:</b> <jk>null</jk> + * <li><b>Session-overridable:</b> <jk>true</jk> + * </ul> + * <p> + * Associates an {@link XMLReporter} with this parser. + * <p> + * <h5 class='section'>Notes:</h5> + * <ul> + * <li>Reporters are not copied to new parsers during a clone. + * </ul> + * <p> + * If <jk>true</jk>, string values will be trimmed of whitespace using {@link String#trim()} before being added to the POJO. + * <p> + * <h5 class='section'>Notes:</h5> + * <ul> + * <li>This is equivalent to calling <code>setProperty(<jsf>XML_reporter</jsf>, value)</code>. + * </ul> + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see XmlParserContext#XML_reporter + */ + public XmlParser setReporter(XMLReporter value) throws LockedException { + return setProperty(XML_reporter, value); + } + + /** + * <b>Configuration property:</b> XML resolver. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlParser.resolver"</js> + * <li><b>Data type:</b> {@link XMLResolver} + * <li><b>Default:</b> <jk>null</jk> + * <li><b>Session-overridable:</b> <jk>true</jk> + * </ul> + * <p> + * Associates an {@link XMLResolver} with this parser. + * <p> + * If <jk>true</jk>, string values will be trimmed of whitespace using {@link String#trim()} before being added to the POJO. + * <p> + * <h5 class='section'>Notes:</h5> + * <ul> + * <li>This is equivalent to calling <code>setProperty(<jsf>XML_resolver</jsf>, value)</code>. + * </ul> + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see XmlParserContext#XML_resolver + */ + public XmlParser setResolver(XMLResolver value) throws LockedException { + return setProperty(XML_resolver, value); + } + + /** + * <b>Configuration property:</b> XML event allocator. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlParser.eventAllocator"</js> + * <li><b>Data type:</b> {@link XMLEventAllocator} + * <li><b>Default:</b> <jk>null</jk> + * <li><b>Session-overridable:</b> <jk>true</jk> + * </ul> + * <p> + * Associates an {@link XMLEventAllocator} with this parser. + * <p> + * If <jk>true</jk>, string values will be trimmed of whitespace using {@link String#trim()} before being added to the POJO. + * <p> + * <h5 class='section'>Notes:</h5> + * <ul> + * <li>This is equivalent to calling <code>setProperty(<jsf>XML_eventAllocator</jsf>, value)</code>. + * </ul> + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see XmlParserContext#XML_eventAllocator + */ + public XmlParser setEventAllocator(XMLEventAllocator value) throws LockedException { + return setProperty(XML_eventAllocator, value); + } + + /** + * <b>Configuration property:</b> Preserve root element during generalized parsing. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlParser.preserveRootElement"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * <li><b>Session-overridable:</b> <jk>true</jk> + * </ul> + * <p> + * If <jk>true</jk>, when parsing into a generic {@link ObjectMap}, the map will + * contain a single entry whose key is the root element name. + * + * Example: + * <table class='styled'> + * <tr> + * <td>XML</td> + * <td>ObjectMap.toString(), preserveRootElement==false</td> + * <td>ObjectMap.toString(), preserveRootElement==true</td> + * </tr> + * <tr> + * <td><code><xt><root><a></xt>foobar<xt></a></root></xt></code></td> + * <td><code>{ a:<js>'foobar'</js> }</code></td> + * <td><code>{ root: { a:<js>'foobar'</js> }}</code></td> + * </tr> + * </table> + * <p> + * <h5 class='section'>Notes:</h5> + * <ul> + * <li>This is equivalent to calling <code>setProperty(<jsf>XML_preserveRootElement</jsf>, value)</code>. + * </ul> + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see XmlParserContext#XML_preserveRootElement + */ + public XmlParser setPreserveRootElement(boolean value) throws LockedException { + return setProperty(XML_preserveRootElement, value); + } + + @Override /* Parser */ + public XmlParser setTrimStrings(boolean value) throws LockedException { + super.setTrimStrings(value); + return this; + } + + @Override /* Parser */ + public XmlParser setStrict(boolean value) throws LockedException { + super.setStrict(value); + return this; + } + + @Override /* Parser */ + public XmlParser setInputStreamCharset(String value) throws LockedException { + super.setInputStreamCharset(value); + return this; + } + + @Override /* Parser */ + public XmlParser setFileCharset(String value) throws LockedException { + super.setFileCharset(value); + return this; + } + @Override /* CoreApi */ - public XmlParser setProperty(String property, Object value) throws LockedException { - super.setProperty(property, value); + public XmlParser setBeansRequireDefaultConstructor(boolean value) throws LockedException { + super.setBeansRequireDefaultConstructor(value); return this; } @Override /* CoreApi */ - public XmlParser setProperties(ObjectMap properties) throws LockedException { - super.setProperties(properties); + public XmlParser setBeansRequireSerializable(boolean value) throws LockedException { + super.setBeansRequireSerializable(value); + return this; + } + + @Override /* CoreApi */ + public XmlParser setBeansRequireSettersForGetters(boolean value) throws LockedException { + super.setBeansRequireSettersForGetters(value); + return this; + } + + @Override /* CoreApi */ + public XmlParser setBeansRequireSomeProperties(boolean value) throws LockedException { + super.setBeansRequireSomeProperties(value); + return this; + } + + @Override /* CoreApi */ + public XmlParser setBeanMapPutReturnsOldValue(boolean value) throws LockedException { + super.setBeanMapPutReturnsOldValue(value); + return this; + } + + @Override /* CoreApi */ + public XmlParser setBeanConstructorVisibility(Visibility value) throws LockedException { + super.setBeanConstructorVisibility(value); + return this; + } + + @Override /* CoreApi */ + public XmlParser setBeanClassVisibility(Visibility value) throws LockedException { + super.setBeanClassVisibility(value); + return this; + } + + @Override /* CoreApi */ + public XmlParser setBeanFieldVisibility(Visibility value) throws LockedException { + super.setBeanFieldVisibility(value); + return this; + } + + @Override /* CoreApi */ + public XmlParser setMethodVisibility(Visibility value) throws LockedException { + super.setMethodVisibility(value); + return this; + } + + @Override /* CoreApi */ + public XmlParser setUseJavaBeanIntrospector(boolean value) throws LockedException { + super.setUseJavaBeanIntrospector(value); + return this; + } + + @Override /* CoreApi */ + public XmlParser setUseInterfaceProxies(boolean value) throws LockedException { + super.setUseInterfaceProxies(value); + return this; + } + + @Override /* CoreApi */ + public XmlParser setIgnoreUnknownBeanProperties(boolean value) throws LockedException { + super.setIgnoreUnknownBeanProperties(value); + return this; + } + + @Override /* CoreApi */ + public XmlParser setIgnoreUnknownNullBeanProperties(boolean value) throws LockedException { + super.setIgnoreUnknownNullBeanProperties(value); + return this; + } + + @Override /* CoreApi */ + public XmlParser setIgnorePropertiesWithoutSetters(boolean value) throws LockedException { + super.setIgnorePropertiesWithoutSetters(value); + return this; + } + + @Override /* CoreApi */ + public XmlParser setIgnoreInvocationExceptionsOnGetters(boolean value) throws LockedException { + super.setIgnoreInvocationExceptionsOnGetters(value); + return this; + } + + @Override /* CoreApi */ + public XmlParser setIgnoreInvocationExceptionsOnSetters(boolean value) throws LockedException { + super.setIgnoreInvocationExceptionsOnSetters(value); + return this; + } + + @Override /* CoreApi */ + public XmlParser setSortProperties(boolean value) throws LockedException { + super.setSortProperties(value); + return this; + } + + @Override /* CoreApi */ + public XmlParser setNotBeanPackages(String...values) throws LockedException { + super.setNotBeanPackages(values); + return this; + } + + @Override /* CoreApi */ + public XmlParser setNotBeanPackages(Collection<String> values) throws LockedException { + super.setNotBeanPackages(values); + return this; + } + + @Override /* CoreApi */ + public XmlParser addNotBeanPackages(String...values) throws LockedException { + super.addNotBeanPackages(values); + return this; + } + + @Override /* CoreApi */ + public XmlParser addNotBeanPackages(Collection<String> values) throws LockedException { + super.addNotBeanPackages(values); + return this; + } + + @Override /* CoreApi */ + public XmlParser removeNotBeanPackages(String...values) throws LockedException { + super.removeNotBeanPackages(values); + return this; + } + + @Override /* CoreApi */ + public XmlParser removeNotBeanPackages(Collection<String> values) throws LockedException { + super.removeNotBeanPackages(values); + return this; + } + + @Override /* CoreApi */ + public XmlParser setNotBeanClasses(Class<?>...values) throws LockedException { + super.setNotBeanClasses(values); + return this; + } + + @Override /* CoreApi */ + public XmlParser setNotBeanClasses(Collection<Class<?>> values) throws LockedException { + super.setNotBeanClasses(values); + return this; + } + + @Override /* CoreApi */ + public XmlParser addNotBeanClasses(Class<?>...values) throws LockedException { + super.addNotBeanClasses(values); + return this; + } + + @Override /* CoreApi */ + public XmlParser addNotBeanClasses(Collection<Class<?>> values) throws LockedException { + super.addNotBeanClasses(values); + return this; + } + + @Override /* CoreApi */ + public XmlParser removeNotBeanClasses(Class<?>...values) throws LockedException { + super.removeNotBeanClasses(values); + return this; + } + + @Override /* CoreApi */ + public XmlParser removeNotBeanClasses(Collection<Class<?>> values) throws LockedException { + super.removeNotBeanClasses(values); + return this; + } + + @Override /* CoreApi */ + public XmlParser setBeanFilters(Class<?>...values) throws LockedException { + super.setBeanFilters(values); + return this; + } + + @Override /* CoreApi */ + public XmlParser setBeanFilters(Collection<Class<?>> values) throws LockedException { + super.setBeanFilters(values); + return this; + } + + @Override /* CoreApi */ + public XmlParser addBeanFilters(Class<?>...values) throws LockedException { + super.addBeanFilters(values); + return this; + } + + @Override /* CoreApi */ + public XmlParser addBeanFilters(Collection<Class<?>> values) throws LockedException { + super.addBeanFilters(values); + return this; + } + + @Override /* CoreApi */ + public XmlParser removeBeanFilters(Class<?>...values) throws LockedException { + super.removeBeanFilters(values); + return this; + } + + @Override /* CoreApi */ + public XmlParser removeBeanFilters(Collection<Class<?>> values) throws LockedException { + super.removeBeanFilters(values); + return this; + } + + @Override /* CoreApi */ + public XmlParser setPojoSwaps(Class<?>...values) throws LockedException { + super.setPojoSwaps(values); + return this; + } + + @Override /* CoreApi */ + public XmlParser setPojoSwaps(Collection<Class<?>> values) throws LockedException { + super.setPojoSwaps(values); return this; } @Override /* CoreApi */ - public XmlParser addNotBeanClasses(Class<?>...classes) throws LockedException { - super.addNotBeanClasses(classes); + public XmlParser addPojoSwaps(Class<?>...values) throws LockedException { + super.addPojoSwaps(values); return this; } @Override /* CoreApi */ - public XmlParser addBeanFilters(Class<?>...classes) throws LockedException { - super.addBeanFilters(classes); + public XmlParser addPojoSwaps(Collection<Class<?>> values) throws LockedException { + super.addPojoSwaps(values); return this; } @Override /* CoreApi */ - public XmlParser addPojoSwaps(Class<?>...classes) throws LockedException { - super.addPojoSwaps(classes); + public XmlParser removePojoSwaps(Class<?>...values) throws LockedException { + super.removePojoSwaps(values); return this; } @Override /* CoreApi */ - public XmlParser addToDictionary(Class<?>...classes) throws LockedException { - super.addToDictionary(classes); + public XmlParser removePojoSwaps(Collection<Class<?>> values) throws LockedException { + super.removePojoSwaps(values); return this; } @Override /* CoreApi */ - public <T> XmlParser addImplClass(Class<T> interfaceClass, Class<? extends T> implClass) throws LockedException { + public XmlParser setImplClasses(Map<Class<?>,Class<?>> values) throws LockedException { + super.setImplClasses(values); + return this; + } + + @Override /* CoreApi */ + public <T> CoreApi addImplClass(Class<T> interfaceClass, Class<? extends T> implClass) throws LockedException { super.addImplClass(interfaceClass, implClass); return this; } @Override /* CoreApi */ + public XmlParser setBeanDictionary(Class<?>...values) throws LockedException { + super.setBeanDictionary(values); + return this; + } + + @Override /* CoreApi */ + public XmlParser setBeanDictionary(Collection<Class<?>> values) throws LockedException { + super.setBeanDictionary(values); + return this; + } + + @Override /* CoreApi */ + public XmlParser addToBeanDictionary(Class<?>...values) throws LockedException { + super.addToBeanDictionary(values); + return this; + } + + @Override /* CoreApi */ + public XmlParser addToBeanDictionary(Collection<Class<?>> values) throws LockedException { + super.addToBeanDictionary(values); + return this; + } + + @Override /* CoreApi */ + public XmlParser removeFromBeanDictionary(Class<?>...values) throws LockedException { + super.removeFromBeanDictionary(values); + return this; + } + + @Override /* CoreApi */ + public XmlParser removeFromBeanDictionary(Collection<Class<?>> values) throws LockedException { + super.removeFromBeanDictionary(values); + return this; + } + + @Override /* CoreApi */ + public XmlParser setBeanTypePropertyName(String value) throws LockedException { + super.setBeanTypePropertyName(value); + return this; + } + + @Override /* CoreApi */ + public XmlParser setDefaultParser(Class<?> value) throws LockedException { + super.setDefaultParser(value); + return this; + } + + @Override /* CoreApi */ + public XmlParser setLocale(Locale value) throws LockedException { + super.setLocale(value); + return this; + } + + @Override /* CoreApi */ + public XmlParser setTimeZone(TimeZone value) throws LockedException { + super.setTimeZone(value); + return this; + } + + @Override /* CoreApi */ + public XmlParser setMediaType(MediaType value) throws LockedException { + super.setMediaType(value); + return this; + } + + @Override /* CoreApi */ + public XmlParser setDebug(boolean value) throws LockedException { + super.setDebug(value); + return this; + } + + @Override /* CoreApi */ + public XmlParser setProperty(String name, Object value) throws LockedException { + super.setProperty(name, value); + return this; + } + + @Override /* CoreApi */ + public XmlParser setProperties(ObjectMap properties) throws LockedException { + super.setProperties(properties); + return this; + } + + @Override /* CoreApi */ + public XmlParser addToProperty(String name, Object value) throws LockedException { + super.addToProperty(name, value); + return this; + } + + @Override /* CoreApi */ + public XmlParser putToProperty(String name, Object key, Object value) throws LockedException { + super.putToProperty(name, key, value); + return this; + } + + @Override /* CoreApi */ + public XmlParser putToProperty(String name, Object value) throws LockedException { + super.putToProperty(name, value); + return this; + } + + @Override /* CoreApi */ + public XmlParser removeFromProperty(String name, Object value) throws LockedException { + super.removeFromProperty(name, value); + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden methods + //-------------------------------------------------------------------------------- + + @Override /* CoreApi */ public XmlParser setClassLoader(ClassLoader classLoader) throws LockedException { super.setClassLoader(classLoader); return this;
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/68dffad1/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserContext.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserContext.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserContext.java index a5b6802..25df977 100644 --- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserContext.java +++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserContext.java @@ -24,66 +24,8 @@ import org.apache.juneau.parser.*; * Context properties are set by calling {@link ContextFactory#setProperty(String, Object)} on the context factory * returned {@link CoreApi#getContextFactory()}. * <p> - * The following convenience methods are also provided for setting context properties: - * <ul> - * <li>{@link XmlParser#setProperty(String,Object)} - * <li>{@link XmlParser#setProperties(ObjectMap)} - * <li>{@link XmlParser#addNotBeanClasses(Class[])} - * <li>{@link XmlParser#addBeanFilters(Class[])} - * <li>{@link XmlParser#addPojoSwaps(Class[])} - * <li>{@link XmlParser#addToDictionary(Class[])} - * <li>{@link XmlParser#addImplClass(Class,Class)} - * </ul> - * <p> * See {@link ContextFactory} for more information about context properties. * - * <h6 class='topic' id='ConfigProperties'>Configurable properties on the XML parser</h6> - * <table class='styled' style='border-collapse: collapse;'> - * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th><th>Session overridable</th></tr> - * <tr> - * <td>{@link #XML_xsiNs}</td> - * <td>XMLSchema-instance namespace URI.</td> - * <td><code>String</code></td> - * <td><js>"http://www.w3.org/2001/XMLSchema-instance"</js></td> - * <td><jk>true</jk></td> - * </tr> - * <tr> - * <td>{@link #XML_validating}</td> - * <td>Enable validation.</td> - * <td><code>Boolean</code></td> - * <td><jk>false</jk></td> - * <td><jk>true</jk></td> - * </tr> - * <tr> - * <td>{@link #XML_reporter}</td> - * <td>XML reporter.</td> - * <td>{@link XMLReporter}</td> - * <td><jk>null</jk></td> - * <td><jk>true</jk></td> - * </tr> - * <tr> - * <td>{@link #XML_resolver}</td> - * <td>XML resolver.</td> - * <td>{@link XMLResolver}</td> - * <td><jk>null</jk></td> - * <td><jk>true</jk></td> - * </tr> - * <tr> - * <td>{@link #XML_eventAllocator}</td> - * <td>XML event allocator.</td> - * <td>{@link XMLEventAllocator}</td> - * <td><jk>null</jk></td> - * <td><jk>true</jk></td> - * </tr> - * <tr> - * <td>{@link #XML_preserveRootElement}</td> - * <td>Preserve root element during generalized parsing.</td> - * <td><code>Boolean</code></td> - * <td><jk>false</jk></td> - * <td><jk>true</jk></td> - * </tr> - * </table> - * * <h5 class='section'>Inherited configurable properties:</h5> * <ul class='javahierarchy'> * <li class='c'><a class="doclink" href="../BeanContext.html#ConfigProperties">BeanContext</a> - Properties associated with handling beans on serializers and parsers. @@ -95,20 +37,6 @@ import org.apache.juneau.parser.*; public class XmlParserContext extends ParserContext { /** - * <b>Configuration property:</b> XMLSchema-instance namespace URI. - * <p> - * <ul> - * <li><b>Name:</b> <js>"XmlParser.xsiNs"</js> - * <li><b>Data type:</b> <code>String</code> - * <li><b>Default:</b> <js>"http://www.w3.org/2001/XMLSchema-instance"</js> - * <li><b>Session-overridable:</b> <jk>true</jk> - * </ul> - * <p> - * The XMLSchema namespace. - */ - public static final String XML_xsiNs = "XmlParser.xsiNs"; - - /** * <b>Configuration property:</b> Enable validation. * <p> * <ul> @@ -199,7 +127,6 @@ public class XmlParserContext extends ParserContext { */ public static final String XML_preserveRootElement = "XmlParser.preserveRootElement"; - final String xsiNs; final boolean validating, preserveRootElement; @@ -216,7 +143,6 @@ public class XmlParserContext extends ParserContext { */ public XmlParserContext(ContextFactory cf) { super(cf); - xsiNs = cf.getProperty(XML_xsiNs, String.class, "http://www.w3.org/2001/XMLSchema-instance"); validating = cf.getProperty(XML_validating, boolean.class, false); preserveRootElement = cf.getProperty(XML_preserveRootElement, boolean.class, false); reporter = cf.getProperty(XML_reporter, XMLReporter.class, null); @@ -228,7 +154,6 @@ public class XmlParserContext extends ParserContext { public ObjectMap asMap() { return super.asMap() .append("XmlParserContext", new ObjectMap() - .append("xsiNs", xsiNs) .append("validating", validating) .append("preserveRootElement", preserveRootElement) .append("reporter", reporter) http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/68dffad1/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserSession.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserSession.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserSession.java index e6a7e13..ebf5d5d 100644 --- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserSession.java +++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlParserSession.java @@ -34,7 +34,6 @@ import org.apache.juneau.xml.annotation.*; */ public class XmlParserSession extends ParserSession { - private final String xsiNs; private final boolean validating, preserveRootElement; @@ -70,14 +69,12 @@ public class XmlParserSession extends ParserSession { public XmlParserSession(XmlParserContext ctx, ObjectMap op, Object input, Method javaMethod, Object outer, Locale locale, TimeZone timeZone, MediaType mediaType) { super(ctx, op, input, javaMethod, outer, locale, timeZone, mediaType); if (op == null || op.isEmpty()) { - xsiNs = ctx.xsiNs; validating = ctx.validating; reporter = ctx.reporter; resolver = ctx.resolver; eventAllocator = ctx.eventAllocator; preserveRootElement = ctx.preserveRootElement; } else { - xsiNs = op.getString(XML_xsiNs, ctx.xsiNs); validating = op.getBoolean(XML_validating, ctx.validating); reporter = (XMLReporter)op.get(XML_reporter, ctx.reporter); resolver = (XMLResolver)op.get(XML_resolver, ctx.resolver); @@ -87,15 +84,6 @@ public class XmlParserSession extends ParserSession { } /** - * Returns the {@link XmlParserContext#XML_xsiNs} setting value for this session. - * - * @return The {@link XmlParserContext#XML_xsiNs} setting value for this session. - */ - public final String getXsiNs() { - return xsiNs; - } - - /** * Returns the {@link XmlParserContext#XML_preserveRootElement} setting value for this session. * * @return The {@link XmlParserContext#XML_preserveRootElement} setting value for this session. http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/68dffad1/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java index 3a86e00..7c38f84 100644 --- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java +++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializer.java @@ -12,7 +12,6 @@ // *************************************************************************************************************************** package org.apache.juneau.xml; -import static org.apache.juneau.serializer.SerializerContext.*; import static org.apache.juneau.xml.XmlSerializerContext.*; import static org.apache.juneau.xml.annotation.XmlFormat.*; import static org.apache.juneau.xml.XmlSerializer.ContentResult.*; @@ -147,7 +146,7 @@ public class XmlSerializer extends WriterSerializer { public static class Sq extends XmlSerializer { /** Constructor */ public Sq() { - setProperty(SERIALIZER_quoteChar, '\''); + setQuoteChar('\''); } } @@ -155,7 +154,7 @@ public class XmlSerializer extends WriterSerializer { public static class SqReadable extends Sq { /** Constructor */ public SqReadable() { - setProperty(SERIALIZER_useIndentation, true); + setUseIndentation(true); } } @@ -164,7 +163,7 @@ public class XmlSerializer extends WriterSerializer { public static class Ns extends XmlSerializer { /** Constructor */ public Ns() { - setProperty(XML_enableNamespaces, true); + setEnableNamespaces(true); } } @@ -172,7 +171,7 @@ public class XmlSerializer extends WriterSerializer { public static class NsSq extends Ns { /** Constructor */ public NsSq() { - setProperty(SERIALIZER_quoteChar, '\''); + setQuoteChar('\''); } } @@ -180,7 +179,7 @@ public class XmlSerializer extends WriterSerializer { public static class NsSqReadable extends NsSq { /** Constructor */ public NsSqReadable() { - setProperty(SERIALIZER_useIndentation, true); + setUseIndentation(true); } } @@ -745,7 +744,7 @@ public class XmlSerializer extends WriterSerializer { //-------------------------------------------------------------------------------- - // Overridden methods + // Entry point methods //-------------------------------------------------------------------------------- @Override /* Serializer */ @@ -761,49 +760,656 @@ public class XmlSerializer extends WriterSerializer { return new XmlSerializerSession(getContext(XmlSerializerContext.class), op, output, javaMethod, locale, timeZone, mediaType); } + + //-------------------------------------------------------------------------------- + // Properties + //-------------------------------------------------------------------------------- + + /** + * <b>Configuration property:</b> Enable support for XML namespaces. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlSerializer.enableNamespaces"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * <li><b>Session-overridable:</b> <jk>true</jk> + * </ul> + * <p> + * If not enabled, XML output will not contain any namespaces regardless of any other settings. + * <p> + * <h5 class='section'>Notes:</h5> + * <ul> + * <li>This is equivalent to calling <code>setProperty(<jsf>XML_enableNamespaces</jsf>, value)</code>. + * <li>This introduces a slight performance penalty. + * </ul> + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see XmlSerializerContext#XML_enableNamespaces + */ + public XmlSerializer setEnableNamespaces(boolean value) throws LockedException { + return setProperty(XML_enableNamespaces, value); + } + + /** + * <b>Configuration property:</b> Auto-detect namespace usage. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlSerializer.autoDetectNamespaces"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>true</jk> + * <li><b>Session-overridable:</b> <jk>true</jk> + * </ul> + * <p> + * Detect namespace usage before serialization. + * <p> + * Used in conjunction with {@link XmlSerializerContext#XML_addNamespaceUrisToRoot} to reduce + * the list of namespace URLs appended to the root element to only those + * that will be used in the resulting document. + * <p> + * If enabled, then the data structure will first be crawled looking for + * namespaces that will be encountered before the root element is + * serialized. + * <p> + * This setting is ignored if {@link XmlSerializerContext#XML_enableNamespaces} is not enabled. + * <p> + * <h5 class='section'>Notes:</h5> + * <ul> + * <li>Auto-detection of namespaces can be costly performance-wise. + * In high-performance environments, it's recommended that namespace detection be + * disabled, and that namespaces be manually defined through the {@link XmlSerializerContext#XML_namespaces} property. + * </ul> + * <p> + * <h5 class='section'>Notes:</h5> + * <ul> + * <li>This is equivalent to calling <code>setProperty(<jsf>XML_autoDetectNamespaces</jsf>, value)</code>. + * <li>This introduces a slight performance penalty. + * </ul> + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see XmlSerializerContext#XML_autoDetectNamespaces + */ + public XmlSerializer setAutoDetectNamespaces(boolean value) throws LockedException { + return setProperty(XML_autoDetectNamespaces, value); + } + + /** + * <b>Configuration property:</b> Add namespace URLs to the root element. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlSerializer.addNamespaceUrisToRoot"</js> + * <li><b>Data type:</b> <code>Boolean</code> + * <li><b>Default:</b> <jk>false</jk> + * <li><b>Session-overridable:</b> <jk>true</jk> + * </ul> + * <p> + * Use this setting to add {@code xmlns:x} attributes to the root + * element for the default and all mapped namespaces. + * <p> + * This setting is ignored if {@link XmlSerializerContext#XML_enableNamespaces} is not enabled. + * <p> + * <h5 class='section'>Notes:</h5> + * <ul> + * <li>This is equivalent to calling <code>setProperty(<jsf>XML_addNamespaceUrisToRoot</jsf>, value)</code>. + * <li>This introduces a slight performance penalty. + * </ul> + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see XmlSerializerContext#XML_addNamespaceUrisToRoot + */ + public XmlSerializer setAddNamespaceUrisToRoot(boolean value) throws LockedException { + return setProperty(XML_addNamespaceUrisToRoot, value); + } + + /** + * <b>Configuration property:</b> Default namespace. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlSerializer.defaultNamespace"</js> + * <li><b>Data type:</b> <code>String</code> + * <li><b>Default:</b> <js>"{juneau:'http://www.apache.org/2013/Juneau'}"</js> + * <li><b>Session-overridable:</b> <jk>true</jk> + * </ul> + * <p> + * Specifies the default namespace URI for this document. + * <p> + * <h5 class='section'>Notes:</h5> + * <ul> + * <li>This is equivalent to calling <code>setProperty(<jsf>XML_defaultNamespace</jsf>, value)</code>. + * <li>This introduces a slight performance penalty. + * </ul> + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see XmlSerializerContext#XML_defaultNamespace + */ + public XmlSerializer setDefaultNamespace(String value) throws LockedException { + return setProperty(XML_defaultNamespace, value); + } + + /** + * <b>Configuration property:</b> XMLSchema namespace. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlSerializer.xsNamespace"</js> + * <li><b>Data type:</b> {@link Namespace} + * <li><b>Default:</b> <code>{name:<js>'xs'</js>,uri:<js>'http://www.w3.org/2001/XMLSchema'</js>}</code> + * <li><b>Session-overridable:</b> <jk>true</jk> + * </ul> + * <p> + * Specifies the namespace for the <code>XMLSchema</code> namespace, used by the schema generated + * by the {@link XmlSchemaSerializer} class. + * <p> + * <h5 class='section'>Notes:</h5> + * <ul> + * <li>This is equivalent to calling <code>setProperty(<jsf>XML_xsNamespace</jsf>, value)</code>. + * <li>This introduces a slight performance penalty. + * </ul> + * + * @param value The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see XmlSerializerContext#XML_xsNamespace + */ + public XmlSerializer setXsNamespace(Namespace value) throws LockedException { + return setProperty(XML_xsNamespace, value); + } + + /** + * <b>Configuration property:</b> Default namespaces. + * <p> + * <ul> + * <li><b>Name:</b> <js>"XmlSerializer.namespaces"</js> + * <li><b>Data type:</b> <code>Set<{@link Namespace}></code> + * <li><b>Default:</b> empty set + * <li><b>Session-overridable:</b> <jk>true</jk> + * </ul> + * <p> + * The default list of namespaces associated with this serializer. + * <p> + * <h5 class='section'>Notes:</h5> + * <ul> + * <li>This is equivalent to calling <code>setProperty(<jsf>XML_namespaces</jsf>, values)</code>. + * <li>This introduces a slight performance penalty. + * </ul> + * + * @param values The new value for this property. + * @return This object (for method chaining). + * @throws LockedException If {@link #lock()} was called on this class. + * @see XmlSerializerContext#XML_namespaces + */ + public XmlSerializer setNamespaces(Namespace...values) throws LockedException { + return setProperty(XML_namespaces, values); + } + + @Override /* Serializer */ + public XmlSerializer setMaxDepth(int value) throws LockedException { + super.setMaxDepth(value); + return this; + } + + @Override /* Serializer */ + public XmlSerializer setInitialDepth(int value) throws LockedException { + super.setInitialDepth(value); + return this; + } + + @Override /* Serializer */ + public XmlSerializer setDetectRecursions(boolean value) throws LockedException { + super.setDetectRecursions(value); + return this; + } + + @Override /* Serializer */ + public XmlSerializer setIgnoreRecursions(boolean value) throws LockedException { + super.setIgnoreRecursions(value); + return this; + } + + @Override /* Serializer */ + public XmlSerializer setUseIndentation(boolean value) throws LockedException { + super.setUseIndentation(value); + return this; + } + + @Override /* Serializer */ + public XmlSerializer setAddBeanTypeProperties(boolean value) throws LockedException { + super.setAddBeanTypeProperties(value); + return this; + } + + @Override /* Serializer */ + public XmlSerializer setQuoteChar(char value) throws LockedException { + super.setQuoteChar(value); + return this; + } + + @Override /* Serializer */ + public XmlSerializer setTrimNullProperties(boolean value) throws LockedException { + super.setTrimNullProperties(value); + return this; + } + + @Override /* Serializer */ + public XmlSerializer setTrimEmptyCollections(boolean value) throws LockedException { + super.setTrimEmptyCollections(value); + return this; + } + + @Override /* Serializer */ + public XmlSerializer setTrimEmptyMaps(boolean value) throws LockedException { + super.setTrimEmptyMaps(value); + return this; + } + + @Override /* Serializer */ + public XmlSerializer setTrimStrings(boolean value) throws LockedException { + super.setTrimStrings(value); + return this; + } + + @Override /* Serializer */ + public XmlSerializer setRelativeUriBase(String value) throws LockedException { + super.setRelativeUriBase(value); + return this; + } + + @Override /* Serializer */ + public XmlSerializer setAbsolutePathUriBase(String value) throws LockedException { + super.setAbsolutePathUriBase(value); + return this; + } + + @Override /* Serializer */ + public XmlSerializer setSortCollections(boolean value) throws LockedException { + super.setSortCollections(value); + return this; + } + + @Override /* Serializer */ + public XmlSerializer setSortMaps(boolean value) throws LockedException { + super.setSortMaps(value); + return this; + } + @Override /* CoreApi */ - public XmlSerializer setProperty(String property, Object value) throws LockedException { - super.setProperty(property, value); + public XmlSerializer setBeansRequireDefaultConstructor(boolean value) throws LockedException { + super.setBeansRequireDefaultConstructor(value); return this; } @Override /* CoreApi */ - public XmlSerializer setProperties(ObjectMap properties) throws LockedException { - super.setProperties(properties); + public XmlSerializer setBeansRequireSerializable(boolean value) throws LockedException { + super.setBeansRequireSerializable(value); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setBeansRequireSettersForGetters(boolean value) throws LockedException { + super.setBeansRequireSettersForGetters(value); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setBeansRequireSomeProperties(boolean value) throws LockedException { + super.setBeansRequireSomeProperties(value); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setBeanMapPutReturnsOldValue(boolean value) throws LockedException { + super.setBeanMapPutReturnsOldValue(value); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setBeanConstructorVisibility(Visibility value) throws LockedException { + super.setBeanConstructorVisibility(value); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setBeanClassVisibility(Visibility value) throws LockedException { + super.setBeanClassVisibility(value); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setBeanFieldVisibility(Visibility value) throws LockedException { + super.setBeanFieldVisibility(value); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setMethodVisibility(Visibility value) throws LockedException { + super.setMethodVisibility(value); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setUseJavaBeanIntrospector(boolean value) throws LockedException { + super.setUseJavaBeanIntrospector(value); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setUseInterfaceProxies(boolean value) throws LockedException { + super.setUseInterfaceProxies(value); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setIgnoreUnknownBeanProperties(boolean value) throws LockedException { + super.setIgnoreUnknownBeanProperties(value); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setIgnoreUnknownNullBeanProperties(boolean value) throws LockedException { + super.setIgnoreUnknownNullBeanProperties(value); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setIgnorePropertiesWithoutSetters(boolean value) throws LockedException { + super.setIgnorePropertiesWithoutSetters(value); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setIgnoreInvocationExceptionsOnGetters(boolean value) throws LockedException { + super.setIgnoreInvocationExceptionsOnGetters(value); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setIgnoreInvocationExceptionsOnSetters(boolean value) throws LockedException { + super.setIgnoreInvocationExceptionsOnSetters(value); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setSortProperties(boolean value) throws LockedException { + super.setSortProperties(value); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setNotBeanPackages(String...values) throws LockedException { + super.setNotBeanPackages(values); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setNotBeanPackages(Collection<String> values) throws LockedException { + super.setNotBeanPackages(values); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer addNotBeanPackages(String...values) throws LockedException { + super.addNotBeanPackages(values); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer addNotBeanPackages(Collection<String> values) throws LockedException { + super.addNotBeanPackages(values); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer removeNotBeanPackages(String...values) throws LockedException { + super.removeNotBeanPackages(values); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer removeNotBeanPackages(Collection<String> values) throws LockedException { + super.removeNotBeanPackages(values); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setNotBeanClasses(Class<?>...values) throws LockedException { + super.setNotBeanClasses(values); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setNotBeanClasses(Collection<Class<?>> values) throws LockedException { + super.setNotBeanClasses(values); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer addNotBeanClasses(Class<?>...values) throws LockedException { + super.addNotBeanClasses(values); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer addNotBeanClasses(Collection<Class<?>> values) throws LockedException { + super.addNotBeanClasses(values); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer removeNotBeanClasses(Class<?>...values) throws LockedException { + super.removeNotBeanClasses(values); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer removeNotBeanClasses(Collection<Class<?>> values) throws LockedException { + super.removeNotBeanClasses(values); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setBeanFilters(Class<?>...values) throws LockedException { + super.setBeanFilters(values); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setBeanFilters(Collection<Class<?>> values) throws LockedException { + super.setBeanFilters(values); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer addBeanFilters(Class<?>...values) throws LockedException { + super.addBeanFilters(values); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer addBeanFilters(Collection<Class<?>> values) throws LockedException { + super.addBeanFilters(values); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer removeBeanFilters(Class<?>...values) throws LockedException { + super.removeBeanFilters(values); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer removeBeanFilters(Collection<Class<?>> values) throws LockedException { + super.removeBeanFilters(values); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setPojoSwaps(Class<?>...values) throws LockedException { + super.setPojoSwaps(values); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setPojoSwaps(Collection<Class<?>> values) throws LockedException { + super.setPojoSwaps(values); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer addPojoSwaps(Class<?>...values) throws LockedException { + super.addPojoSwaps(values); return this; } @Override /* CoreApi */ - public XmlSerializer addNotBeanClasses(Class<?>...classes) throws LockedException { - super.addNotBeanClasses(classes); + public XmlSerializer addPojoSwaps(Collection<Class<?>> values) throws LockedException { + super.addPojoSwaps(values); return this; } @Override /* CoreApi */ - public XmlSerializer addBeanFilters(Class<?>...classes) throws LockedException { - super.addBeanFilters(classes); + public XmlSerializer removePojoSwaps(Class<?>...values) throws LockedException { + super.removePojoSwaps(values); return this; } @Override /* CoreApi */ - public XmlSerializer addPojoSwaps(Class<?>...classes) throws LockedException { - super.addPojoSwaps(classes); + public XmlSerializer removePojoSwaps(Collection<Class<?>> values) throws LockedException { + super.removePojoSwaps(values); return this; } @Override /* CoreApi */ - public XmlSerializer addToDictionary(Class<?>...classes) throws LockedException { - super.addToDictionary(classes); + public XmlSerializer setImplClasses(Map<Class<?>,Class<?>> values) throws LockedException { + super.setImplClasses(values); return this; } @Override /* CoreApi */ - public <T> XmlSerializer addImplClass(Class<T> interfaceClass, Class<? extends T> implClass) throws LockedException { + public <T> CoreApi addImplClass(Class<T> interfaceClass, Class<? extends T> implClass) throws LockedException { super.addImplClass(interfaceClass, implClass); return this; } @Override /* CoreApi */ + public XmlSerializer setBeanDictionary(Class<?>...values) throws LockedException { + super.setBeanDictionary(values); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setBeanDictionary(Collection<Class<?>> values) throws LockedException { + super.setBeanDictionary(values); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer addToBeanDictionary(Class<?>...values) throws LockedException { + super.addToBeanDictionary(values); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer addToBeanDictionary(Collection<Class<?>> values) throws LockedException { + super.addToBeanDictionary(values); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer removeFromBeanDictionary(Class<?>...values) throws LockedException { + super.removeFromBeanDictionary(values); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer removeFromBeanDictionary(Collection<Class<?>> values) throws LockedException { + super.removeFromBeanDictionary(values); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setBeanTypePropertyName(String value) throws LockedException { + super.setBeanTypePropertyName(value); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setDefaultParser(Class<?> value) throws LockedException { + super.setDefaultParser(value); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setLocale(Locale value) throws LockedException { + super.setLocale(value); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setTimeZone(TimeZone value) throws LockedException { + super.setTimeZone(value); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setMediaType(MediaType value) throws LockedException { + super.setMediaType(value); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setDebug(boolean value) throws LockedException { + super.setDebug(value); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setProperty(String name, Object value) throws LockedException { + super.setProperty(name, value); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer setProperties(ObjectMap properties) throws LockedException { + super.setProperties(properties); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer addToProperty(String name, Object value) throws LockedException { + super.addToProperty(name, value); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer putToProperty(String name, Object key, Object value) throws LockedException { + super.putToProperty(name, key, value); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer putToProperty(String name, Object value) throws LockedException { + super.putToProperty(name, value); + return this; + } + + @Override /* CoreApi */ + public XmlSerializer removeFromProperty(String name, Object value) throws LockedException { + super.removeFromProperty(name, value); + return this; + } + + + //-------------------------------------------------------------------------------- + // Overridden methods + //-------------------------------------------------------------------------------- + + @Override /* CoreApi */ public XmlSerializer setClassLoader(ClassLoader classLoader) throws LockedException { super.setClassLoader(classLoader); return this; http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/68dffad1/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerContext.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerContext.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerContext.java index 215a5e1..181eaa4 100644 --- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerContext.java +++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlSerializerContext.java @@ -21,66 +21,8 @@ import org.apache.juneau.serializer.*; * Context properties are set by calling {@link ContextFactory#setProperty(String, Object)} on the context factory * returned {@link CoreApi#getContextFactory()}. * <p> - * The following convenience methods are also provided for setting context properties: - * <ul> - * <li>{@link XmlSerializer#setProperty(String,Object)} - * <li>{@link XmlSerializer#setProperties(ObjectMap)} - * <li>{@link XmlSerializer#addNotBeanClasses(Class[])} - * <li>{@link XmlSerializer#addBeanFilters(Class[])} - * <li>{@link XmlSerializer#addPojoSwaps(Class[])} - * <li>{@link XmlSerializer#addToDictionary(Class[])} - * <li>{@link XmlSerializer#addImplClass(Class,Class)} - * </ul> - * <p> * See {@link ContextFactory} for more information about context properties. * - * <h6 class='topic' id='ConfigProperties'>Configurable properties on the XML serializer</h6> - * <table class='styled' style='border-collapse: collapse;'> - * <tr><th>Setting name</th><th>Description</th><th>Data type</th><th>Default value</th><th>Session overridable</th></tr> - * <tr> - * <td>{@link #XML_enableNamespaces}</td> - * <td>Enable support for XML namespaces.</td> - * <td><code>Boolean</code></td> - * <td><jk>false</jk></td> - * <td><jk>true</jk></td> - * </tr> - * <tr> - * <td>{@link #XML_autoDetectNamespaces}</td> - * <td>Auto-detect namespace usage.</td> - * <td><code>Boolean</code></td> - * <td><jk>true</jk></td> - * <td><jk>true</jk></td> - * </tr> - * <tr> - * <td>{@link #XML_addNamespaceUrisToRoot}</td> - * <td>Add namespace URLs to the root element.</td> - * <td><code>Boolean</code></td> - * <td><jk>false</jk></td> - * <td><jk>true</jk></td> - * </tr> - * <tr> - * <td>{@link #XML_defaultNamespace}</td> - * <td>Default namespace URI.</td> - * <td><code>String</code></td> - * <td><jk>null</jk></td> - * <td><jk>true</jk></td> - * </tr> - * <tr> - * <td>{@link #XML_xsNamespace}</td> - * <td>XMLSchema namespace.</td> - * <td>{@link Namespace}</td> - * <td><code>{name:<js>'xs'</js>,uri:<js>'http://www.w3.org/2001/XMLSchema'</js>}</code></td> - * <td><jk>true</jk></td> - * </tr> - * <tr> - * <td>{@link #XML_namespaces}</td> - * <td>Default namespaces.</td> - * <td><code>Set<{@link Namespace}></code></td> - * <td>empty set</td> - * <td><jk>true</jk></td> - * </tr> - * </table> - * * <h5 class='section'>Inherited configurable properties:</h5> * <ul class='javahierarchy'> * <li class='c'><a class="doclink" href="../BeanContext.html#ConfigProperties">BeanContext</a> - Properties associated with handling beans on serializers and parsers. http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/68dffad1/juneau-core/src/main/java/org/apache/juneau/xml/XmlUtils.java ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/XmlUtils.java b/juneau-core/src/main/java/org/apache/juneau/xml/XmlUtils.java index 76e8a0a..fe92575 100644 --- a/juneau-core/src/main/java/org/apache/juneau/xml/XmlUtils.java +++ b/juneau-core/src/main/java/org/apache/juneau/xml/XmlUtils.java @@ -205,6 +205,7 @@ public final class XmlUtils { return l; } + //-------------------------------------------------------------------------------- // Encode XML attributes //-------------------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/68dffad1/juneau-core/src/main/java/org/apache/juneau/xml/package.html ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/java/org/apache/juneau/xml/package.html b/juneau-core/src/main/java/org/apache/juneau/xml/package.html index 9c23da6..2e60821 100644 --- a/juneau-core/src/main/java/org/apache/juneau/xml/package.html +++ b/juneau-core/src/main/java/org/apache/juneau/xml/package.html @@ -238,9 +238,9 @@ <p class='bcode'> <jc>// Create a new serializer with readable output, no namespaces yet.</jc> XmlSerializer s = <jk>new</jk> XmlSerializer() - .setProperty(SerializerContext.<jsf>SERIALIZER_useIndentation</jsf>, <jk>true</jk>) - .setProperty(SerializerContext.<jsf>SERIALIZER_quoteChar</jsf>, <js>'\''</js>) - .setProperty(XmlSerializerContext.<jsf>XML_enableNamespaces</jsf>, <jk>false</jk>); + .setUseIndentation(<jk>true</jk>) + .setQuoteChar(<js>'\''</js>) + .setEnableNamespaces(<jk>false</jk>); <jc>// Create our bean.</jc> Person p = <jk>new</jk> Person(1, <js>"John Smith"</js>); @@ -254,7 +254,7 @@ <p class='bcode'> <jc>// Create a new serializer with readable output, no namespaces yet, but use cloning method.</jc> XmlSerializer s = XmlSerializer.<jsf>DEFAULT_SQ_READABLE</jsf>.clone() - .setProperty(XmlSerializerContext.<jsf>XML_enableNamespaces</jsf>, <jk>false</jk>); + .setEnableNamespaces(<jk>false</jk>); </p> <p> The code above produces the following output: @@ -1984,9 +1984,9 @@ <jc>// Create a new serializer with readable output, this time with namespaces enabled.</jc> <jc>// Note that this is identical to XmlSerializer.DEFAULT_NS_SQ_READABLE.</jc> XmlSerializer s = <jk>new</jk> XmlSerializer() - .setProperty(XmlSerializerContext.<jsf>XML_enableNamespaces</jsf>, <jk>true</jk>) - .setProperty(SerializerContext.<jsf>SERIALIZER_useIndentation</jsf>, <jk>true</jk>) - .setProperty(SerializerContext.<jsf>SERIALIZER_quoteChar</jsf>, <js>'\''</js>); + .setEnableNamespaces(<jk>true</jk>) + .setUseIndentation(<jk>true</jk>) + .setQuoteChar(<js>'\''</js>); <jc>// Create our bean.</jc> Person p = <jk>new</jk> Person(1, <js>"John Smith"</js>); @@ -2073,10 +2073,10 @@ <p class='bcode'> <jc>// Create a new serializer with readable output, this time with namespaces enabled.</jc> XmlSerializer s = <jk>new</jk> XmlSerializer() - .setProperty(SerializerContext.<jsf>SERIALIZER_useIndentation</jsf>, <jk>true</jk>) - .setProperty(SerializerContext.<jsf>SERIALIZER_quoteChar</jsf>, <js>'\''</js>) - .setProperty(XmlSerializerContext.<jsf>XML_enableNamespaces</jsf>, <jk>true</jk>) - .setProperty(XmlSerializerContext.<jsf>XML_defaultNamespaceUri</jsf>, <js>"http://www.apache.org/person/"</js>); + .setUseIndentation(<jk>true</jk>) + .setQuoteChar(<js>'\''</js>) + .setEnableNamespaces(<jk>true</jk>) + .setDefaultNamespaceUri(<js>"http://www.apache.org/person/"</js>); </p> <p> This produces the following equivalent where the elements don't need prefixes since they're already in the default document namespace: @@ -2107,10 +2107,10 @@ <p class='bcode'> <jc>// Create a new serializer with readable output, this time with namespaces enabled.</jc> XmlSerializer s = <jk>new</jk> XmlSerializer() - .setProperty(SerializerContext.<jsf>SERIALIZER_useIndentation</jsf>, <jk>true</jk>) - .setProperty(SerializerContext.<jsf>SERIALIZER_quoteChar</jsf>, <js>'\''</js>) - .setProperty(XmlSerializerContext.<jsf>XML_autoDetectNamespaces</jsf>, <jk>false</jk>) - .setProperty(XmlSerializerContext.<jsf>XML_namespaces</jsf>, <js>"{per:'http://www.apache.org/person/'}"</js>); + .setUseIndentation(<jk>true</jk>) + .setQuoteChar(<js>'\''</js>) + .setAutoDetectNamespaces(<jk>false</jk>) + .setNamespaces(<js>"{per:'http://www.apache.org/person/'}"</js>); </p> </div> @@ -2241,8 +2241,8 @@ <p class='bcode'> <jc>// Create a new serializer with readable output.</jc> XmlSerializer s = <jk>new</jk> XmlSerializer() - .setProperty(SerializerContext.<jsf>SERIALIZER_useIndentation</jsf>, <jk>true</jk>) - .setProperty(SerializerContext.<jsf>SERIALIZER_quoteChar</jsf>, <js>'\''</js>); + .setUseIndentation(<jk>true</jk>) + .setQuoteChar(<js>'\''</js>); <jc>// Create our bean.</jc> Person p = <jk>new</jk> Person(1, <js>"John Smith"</js>, <js>"http://sample/addressBook/person/1"</js>, <js>"http://sample/addressBook"</js>, <js>"Aug 12, 1946"</js>); @@ -2354,10 +2354,10 @@ <p class='bcode'> <jc>// Create a new serializer with readable output.</jc> XmlSerializer s = <jk>new</jk> XmlSerializer() - .setProperty(SerializerContext.<jsf>SERIALIZER_useIndentation</jsf>, <jk>true</jk>) - .setProperty(XmlSerializerContext.<jsf>XML_enableNamespaces</jsf>, <jk>true</jk>) - .setProperty(XmlSerializerContext.<jsf>XML_addNamespaceUrisToRoot</jsf>, <jk>true</jk>) - .setProperty(SerializerContext.<jsf>SERIALIZER_quoteChar</jsf>, <js>'\''</js>); + .setUseIndentation(<jk>true</jk>) + .setEnableNamespaces(<jk>true</jk>) + .setAddNamespaceUrisToRoot(<jk>true</jk>) + .setQuoteChar(<js>'\''</js>); <jc>// Create the equivalent schema serializer.</jc> XmlSchemaSerializer ss = s.getSchemaSerializer(); @@ -2656,10 +2656,10 @@ <p class='bcode'> <jc>// Create a new serializer with readable output.</jc> XmlSerializer s = <jk>new</jk> XmlSerializer() - .setProperty(SerializerContext.<jsf>SERIALIZER_useIndentation</jsf>, <jk>true</jk>) - .setProperty(SerializerContext.<jsf>SERIALIZER_quoteChar</jsf>, <js>'\''</js>) - .setProperty(XmlSerializerContext.<jsf>XML_enableNamespaces</jsf>, <jk>false</jk>) - .setProperty(SerializerContext.<jsf>SERIALIZER_detectRecursions</jsf>, <jk>true</jk>); + .setUseIndentation(<jk>true</jk>) + .setQuoteChar(<js>'\''</js>) + .setEnableNamespaces(<jk>false</jk>) + .setDetectRecursions(<jk>true</jk>); <jc>// Create a recursive loop.</jc> A a = <jk>new</jk> A(); @@ -2736,9 +2736,9 @@ <p class='bcode'> <jc>// Create a new serializer with readable output.</jc> XmlSerializer s = <jk>new</jk> XmlSerializer() - .setProperty(XmlSerializerContext.<jsf>XML_enableNamespaces</jsf>, <jk>true</jk>) - .setProperty(SerializerContext.<jsf>SERIALIZER_useIndentation</jsf>, <jk>true</jk>) - .setProperty(SerializerContext.<jsf>SERIALIZER_quoteChar</jsf>, <js>'\''</js>); + .setEnableNamespaces(<jk>true</jk>) + .setUseIndentation(<jk>true</jk>) + .setQuoteChar(<js>'\''</js>); <jc>// Create our bean.</jc> Person p = <jk>new</jk> Person(1, <js>"John Smith"</js>, <js>"http://sample/addressBook/person/1"</js>, <js>"http://sample/addressBook"</js>, <js>"Aug 12, 1946"</js>); http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/68dffad1/juneau-core/src/main/javadoc/overview.html ---------------------------------------------------------------------- diff --git a/juneau-core/src/main/javadoc/overview.html b/juneau-core/src/main/javadoc/overview.html index ce52a4e..b238c64 100644 --- a/juneau-core/src/main/javadoc/overview.html +++ b/juneau-core/src/main/javadoc/overview.html @@ -334,12 +334,12 @@ <jc>// Create a custom serializer for lax syntax using single quote characters</jc> JsonSerializer serializer = <jk>new</jk> JsonSerializer() - .setProperty(JsonSerializerContext.<jsf>JSON_simpleMode</jsf>, <jk>true</jk>) - .setProperty(SerializerContext.<jsf>SERIALIZER_quoteChar</jsf>, <js>'\''</js>); + .setSimpleMode(<jk>true</jk>) + .setQuoteChar(<js>'\''</js>); <jc>// Clone an existing serializer and modify it to use single-quotes</jc> JsonSerializer serializer = JsonSerializer.<jsf>DEFAULT</jsf>.clone() - .setProperty(SerializerContext.<jsf>SERIALIZER_quoteChar</jsf>, <js>'\''</js>); + .setQuoteChar(<js>'\''</js>); <jc>// Serialize a POJO to JSON</jc> String json = serializer.serialize(someObject); @@ -448,8 +448,8 @@ <jc>// Construct a new serializer group with configuration parameters that get applied to all serializers.</jc> SerializerGroup sg = <jk>new</jk> SerializerGroup() .append(JsonSerializer.<jk>class</jk>, UrlEncodingSerializer.<jk>class</jk>); - .setProperty(SerializerContext.<jsf>SERIALIZER_useIndentation</jsf>, <jk>true</jk>) - .addTransforms(CalendarSwap.ISO8601DT.<jk>class</jk>); + .setUseIndentation(<jk>true</jk>) + .addPojoSwaps(CalendarSwap.ISO8601DT.<jk>class</jk>); <jc>// Find the appropriate serializer by Accept type and serialize our POJO to the specified writer.</jc> sg.getSerializer(<js>"text/invalid, text/json;q=0.8, text/*;q:0.6, *\/*;q=0.0"</js>) @@ -549,10 +549,10 @@ </p> <p class='bcode'> JsonSerializer s = <jk>new</jk> JsonSerializer() - .setProperty(SerializerContext.<jsf>SERIALIZER_useIndentation</jsf>, <jk>true</jk>) - .setProperty(JsonSerializerContext.<jsf>JSON_useWhitespace</jsf>, <jk>true</jk>) - .setProperty(JsonSerializerContext.<jsf>JSON_simpleMode</jsf>, <jk>true</jk>) - .setProperty(SerializerContext.<jsf>SERIALIZER_quoteChar</jsf>, <js>'\''</js>); + .setUseIndentation(<jk>true</jk>) + .setUseWhitespace(<jk>true</jk>) + .setSimpleMode(<jk>true</jk>) + .setQuoteChar(<js>'\''</js>); </p> <p> However, each of the serializers and parsers already contain reusable instances with common configurations.<br> @@ -587,7 +587,7 @@ <jc>// Clone and customize an existing serializer.</jc> JsonSerializer s = JsonSerializer.<jsf>DEFAULT_LAX</jsf> .clone() - .setProperty(SerializerContext.<jsf>SERIALIZER_quoteChar</jsf>, <js>'"'</js>); + .setQuoteChar(<js>'"'</js>); <jc>// Lock it so that the configuration cannot be changed.</jc> s.lock(); @@ -1023,7 +1023,7 @@ </p> <ul> <li>On individual bean properties through the {@link org.apache.juneau.annotation.BeanProperty#beanDictionary() @BeanProperty.beanDictionary()} annotation. - <li>Globally for a parser using the {@link org.apache.juneau.parser.Parser#addToDictionary(Class...)} method. + <li>Globally for a parser using the {@link org.apache.juneau.parser.Parser#addToBeanDictionary(Class...)} method. </ul> <p class='info'> Type names do not need to be universally unique. @@ -2969,8 +2969,8 @@ serializerGroup .addBeanFilters(HttpServletRequest.<jk>class</jk>, HttpSession.<jk>class</jk>, ServletContext.<jk>class</jk>) .addPojoSwaps(EnumerationSwap.<jk>class</jk>) - .setProperty(<jsf>SERIALIZER_maxDepth</jsf>, 10) - .setProperty(<jsf>SERIALIZER_detectRecursions</jsf>, <jk>true</jk>); + .setMaxDepth(10) + .setDetectRecursions(<jk>true</jk>); .setProperty(<jsf>HTMLDOC_links</jsf>, <js>"{...}"</js>); <jc>// Return the updated group</jc> @@ -5472,9 +5472,46 @@ <li>{@link org.apache.juneau.parser.Parser#parse(Object,Class)} - Normal method. <li>{@link org.apache.juneau.parser.Parser#parse(Object,Type,Type...)} - Method for parsing into parameterized maps and collections. </ul> + Using these methods, you can construct arbitrarily complex objects consisting of maps and collections. + You could do this before, but it required constructing a <code>ClassMeta</code> object. + <br>For example: + <p class='bcode'> + <jc>// Old way:</jc> + ClassMeta<?> cm = parser.getMapClassMeta( + HashMap.<jk>class</jk>, + String.<jk>class</jk>, + parser.getCollectionClassMeta( + LinkedList.<jk>class</jk>, + MyBean.<jk>class</jk> + ) + ); + Map<String,List<MyBean>> map = (Map<String,List<MyBean>>)parser.parse(input, cm); + + <jc>// New way:</jc> + Map<String,List<MyBean>> map = parser.parse(input, HashMap.<jk>class</jk>, String.<jk>class</jk>, LinkedList.<jk>class</jk>, MyBean.<jk>class</jk>); + </p> <li>Arbitrarily-complex parameterized maps and collections can now be parsed without the need for creating intermediate <code>ClassMeta</code> objects. <li>No need for casting anymore if you were using the old <code>parseMap()</code> and <code>parseCollection()</code> methods! <li>Changes allow me to eliminate <code>BeanContext.normalizeClassMeta()</code> method. + <li>Convenience methods added for setting parser properties: + <p class='bcode'> + <jc>// Old way:</jc> + <jk>new</jk> JsonParser().setProperty(<jsf>PARSER_strict</jsf>, <jk>true</jk>).setProperty(<jsf>BEAN_locale</jsf>, mylocale); + + <jc>// New way:</jc> + <jk>new</jk> JsonParser().setStrict(<jk>true</jk>).setLocale(mylocale); + </p> + </ul> + <li>Improvements to Serializer class: + <ul> + <li>Convenience methods added for setting serializer properties: + <p class='bcode'> + <jc>// Old way:</jc> + <jk>new</jk> JsonSerializer().setProperty(<jsf>JSON_simpleMode</jsf>, <jk>true</jk>).setProperty(<jsf>SERIALIZER_quoteChar</jsf>, <js>'"'</js>); + + <jc>// New way:</jc> + <jk>new</jk> JsonSerializer().setSimpleMode(<jk>true</jk>).setQuoteChar(<js>'"'</js>); + </p> </ul> <li>Simplified {@link org.apache.juneau.transform.PojoSwap} class. Now just two methods: <ul> http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/68dffad1/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/AddressBookResourceTest.java ---------------------------------------------------------------------- diff --git a/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/AddressBookResourceTest.java b/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/AddressBookResourceTest.java index d504ee6..67ae42a 100644 --- a/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/AddressBookResourceTest.java +++ b/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/AddressBookResourceTest.java @@ -14,6 +14,7 @@ package org.apache.juneau.examples.rest; import static org.apache.juneau.examples.rest.TestUtils.*; import static org.junit.Assert.*; +import static org.apache.juneau.xml.XmlSerializerContext.*; import java.util.*; @@ -45,7 +46,7 @@ public class AddressBookResourceTest { for (RestClient c : clients) { c.getSerializer().addPojoSwaps(CalendarSwap.DateMedium.class); c.getParser().addPojoSwaps(CalendarSwap.DateMedium.class); - c.getSerializer().setProperty(XmlSerializerContext.XML_autoDetectNamespaces, true); + c.getSerializer().setProperty(XML_autoDetectNamespaces, true); } } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/68dffad1/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/SampleRemoteableServicesResourceTest.java ---------------------------------------------------------------------- diff --git a/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/SampleRemoteableServicesResourceTest.java b/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/SampleRemoteableServicesResourceTest.java index 90e8e7b..945e14a 100644 --- a/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/SampleRemoteableServicesResourceTest.java +++ b/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/SampleRemoteableServicesResourceTest.java @@ -13,6 +13,7 @@ package org.apache.juneau.examples.rest; import static org.junit.Assert.*; +import static org.apache.juneau.xml.XmlSerializerContext.*; import org.apache.juneau.examples.addressbook.*; import org.apache.juneau.json.*; @@ -37,7 +38,7 @@ public class SampleRemoteableServicesResourceTest { for (RestClient c : clients) { c.addPojoSwaps(CalendarSwap.DateMedium.class); c.setRemoteableServletUri("/remoteable"); - c.setProperty(XmlSerializerContext.XML_autoDetectNamespaces, true); + c.setProperty(XML_autoDetectNamespaces, true); } } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/68dffad1/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/TestUtils.java ---------------------------------------------------------------------- diff --git a/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/TestUtils.java b/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/TestUtils.java index 970cc47..39463dd 100644 --- a/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/TestUtils.java +++ b/juneau-examples-rest/src/test/java/org/apache/juneau/examples/rest/TestUtils.java @@ -12,9 +12,6 @@ // *************************************************************************************************************************** package org.apache.juneau.examples.rest; -import static org.apache.juneau.BeanContext.*; -import static org.apache.juneau.serializer.SerializerContext.*; -import static org.apache.juneau.xml.XmlSerializerContext.*; import static org.junit.Assert.*; import java.io.*; @@ -43,12 +40,12 @@ import org.xml.sax.*; public class TestUtils { private static JsonSerializer js = new JsonSerializer.Simple() - .setProperty(SERIALIZER_trimNullProperties, false); + .setTrimNullProperties(false); private static JsonSerializer jsSorted = new JsonSerializer.Simple() - .setProperty(SERIALIZER_sortCollections, true) - .setProperty(SERIALIZER_sortMaps, true) - .setProperty(SERIALIZER_trimNullProperties, false); + .setSortCollections(true) + .setSortMaps(true) + .setTrimNullProperties(false); private static JsonSerializer js2 = new JsonSerializer.Simple() @@ -56,7 +53,7 @@ public class TestUtils { private static JsonSerializer js3 = new JsonSerializer.Simple() .addPojoSwaps(IteratorSwap.class, EnumerationSwap.class) - .setProperty(BEAN_sortProperties, true); + .setSortProperties(true); /** * Verifies that two objects are equivalent. @@ -224,7 +221,7 @@ public class TestUtils { * Test whitespace and generated schema. */ public static void validateXml(Object o, XmlSerializer s) throws Exception { - s = s.clone().setProperty(SERIALIZER_useIndentation, true).setProperty(XML_enableNamespaces, true).setProperty(XML_addNamespaceUrisToRoot, true); + s = s.clone().setUseIndentation(true).setEnableNamespaces(true).setAddNamespaceUrisToRoot(true); String xml = s.serialize(o); String xmlSchema = null; http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/68dffad1/juneau-microservice/src/main/java/org/apache/juneau/microservice/Microservice.java ---------------------------------------------------------------------- diff --git a/juneau-microservice/src/main/java/org/apache/juneau/microservice/Microservice.java b/juneau-microservice/src/main/java/org/apache/juneau/microservice/Microservice.java index e604231..0d0b7c4 100755 --- a/juneau-microservice/src/main/java/org/apache/juneau/microservice/Microservice.java +++ b/juneau-microservice/src/main/java/org/apache/juneau/microservice/Microservice.java @@ -382,6 +382,7 @@ public abstract class Microservice { return mf; } + //-------------------------------------------------------------------------------- // Abstract lifecycle methods. //-------------------------------------------------------------------------------- @@ -551,6 +552,7 @@ public abstract class Microservice { System.exit(2); } + //-------------------------------------------------------------------------------- // Lifecycle listener methods. // Subclasses can override these methods to run code on certain events. http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/68dffad1/juneau-microservice/src/main/java/org/apache/juneau/microservice/RestMicroservice.java ---------------------------------------------------------------------- diff --git a/juneau-microservice/src/main/java/org/apache/juneau/microservice/RestMicroservice.java b/juneau-microservice/src/main/java/org/apache/juneau/microservice/RestMicroservice.java index a86eb4c..fe46dca 100755 --- a/juneau-microservice/src/main/java/org/apache/juneau/microservice/RestMicroservice.java +++ b/juneau-microservice/src/main/java/org/apache/juneau/microservice/RestMicroservice.java @@ -92,6 +92,7 @@ public class RestMicroservice extends Microservice { super(args); } + //-------------------------------------------------------------------------------- // Methods implemented on Microservice API //-------------------------------------------------------------------------------- @@ -138,6 +139,7 @@ public class RestMicroservice extends Microservice { return this; } + //-------------------------------------------------------------------------------- // RestMicroservice API methods. //-------------------------------------------------------------------------------- @@ -483,6 +485,7 @@ public class RestMicroservice extends Microservice { } } + //-------------------------------------------------------------------------------- // Lifecycle listener methods. //-------------------------------------------------------------------------------- @@ -522,6 +525,7 @@ public class RestMicroservice extends Microservice { */ protected void onPostStopServer() {} + //-------------------------------------------------------------------------------- // Other methods. //-------------------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/68dffad1/juneau-microservice/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java ---------------------------------------------------------------------- diff --git a/juneau-microservice/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java b/juneau-microservice/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java index 90a73c2..19e1757 100755 --- a/juneau-microservice/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java +++ b/juneau-microservice/src/main/java/org/apache/juneau/microservice/resources/DirectoryResource.java @@ -110,7 +110,7 @@ public class DirectoryResource extends Resource { * @param req The HTTP request. * @return Either a FileResource or list of FileResources depending on whether it's a * file or directory. - * @throws Exception - If file could not be read or access was not granted. + * @throws Exception If file could not be read or access was not granted. */ @RestMethod(name="GET", path="/*", description="On directories, returns a directory listing.\nOn files, returns information about the file.", @@ -148,7 +148,7 @@ public class DirectoryResource extends Resource { * * @param req The HTTP request. * @return The message <js>"File deleted"</js> if successful. - * @throws Exception - If file could not be read or access was not granted. + * @throws Exception If file could not be read or access was not granted. */ @RestMethod(name="DELETE", path="/*", description="Delete a file on the file system." @@ -170,7 +170,7 @@ public class DirectoryResource extends Resource { * * @param req The HTTP request. * @return The message <js>"File added"</js> if successful. - * @throws Exception - If file could not be read or access was not granted. + * @throws Exception If file could not be read or access was not granted. */ @RestMethod(name="PUT", path="/*", description="Add or overwrite a file on the file system." @@ -195,7 +195,7 @@ public class DirectoryResource extends Resource { * @param req The HTTP request. * @param res The HTTP response. * @return A Reader containing the contents of the file. - * @throws Exception - If file could not be read or access was not granted. + * @throws Exception If file could not be read or access was not granted. */ @RestMethod(name="VIEW", path="/*", description="View the contents of a file.\nApplies to files only." @@ -223,7 +223,7 @@ public class DirectoryResource extends Resource { * @param req The HTTP request. * @param res The HTTP response. * @return A Reader containing the contents of the file. - * @throws Exception - If file could not be read or access was not granted. + * @throws Exception If file could not be read or access was not granted. */ @RestMethod(name="DOWNLOAD", path="/*", description="Download the contents of a file.\nApplies to files only." http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/68dffad1/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java ---------------------------------------------------------------------- diff --git a/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java b/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java index 54ee36d..6041d6d 100644 --- a/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java +++ b/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java @@ -922,14 +922,14 @@ public class RestClient extends CoreApi { } @Override /* CoreAPI */ - public RestClient addToDictionary(Class<?>...classes) throws LockedException { - super.addToDictionary(classes); + public RestClient addToBeanDictionary(Class<?>...classes) throws LockedException { + super.addToBeanDictionary(classes); if (serializer != null) - serializer.addToDictionary(classes); + serializer.addToBeanDictionary(classes); if (parser != null) - parser.addToDictionary(classes); + parser.addToBeanDictionary(classes); if (urlEncodingSerializer != null) - urlEncodingSerializer.addToDictionary(classes); + urlEncodingSerializer.addToBeanDictionary(classes); return this; } http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/68dffad1/juneau-rest/src/main/java/org/apache/juneau/rest/ResponseHandler.java ---------------------------------------------------------------------- diff --git a/juneau-rest/src/main/java/org/apache/juneau/rest/ResponseHandler.java b/juneau-rest/src/main/java/org/apache/juneau/rest/ResponseHandler.java index 8144782..6607e64 100644 --- a/juneau-rest/src/main/java/org/apache/juneau/rest/ResponseHandler.java +++ b/juneau-rest/src/main/java/org/apache/juneau/rest/ResponseHandler.java @@ -85,8 +85,8 @@ public interface ResponseHandler { * @param res The HTTP servlet response; * @param output The POJO returned by the REST method that now needs to be sent to the response. * @return true If this handler handled the response. - * @throws IOException - If low-level exception occurred on output stream. Results in a {@link HttpServletResponse#SC_INTERNAL_SERVER_ERROR} error. - * @throws RestException - If some other exception occurred. Can be used to provide an appropriate HTTP response code and message. + * @throws IOException If low-level exception occurred on output stream. Results in a {@link HttpServletResponse#SC_INTERNAL_SERVER_ERROR} error. + * @throws RestException If some other exception occurred. Can be used to provide an appropriate HTTP response code and message. */ boolean handle(RestRequest req, RestResponse res, Object output) throws IOException, RestException; }
