org.apache.juneau.xml.XmlParserBuilder Maven / Gradle / Ivy
// ***************************************************************************************************************************
// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
// * with the License. You may obtain a copy of the License at *
// * *
// * http://www.apache.org/licenses/LICENSE-2.0 *
// * *
// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
// * specific language governing permissions and limitations under the License. *
// ***************************************************************************************************************************
package org.apache.juneau.xml;
import static org.apache.juneau.xml.XmlParser.*;
import java.util.*;
import javax.xml.stream.*;
import javax.xml.stream.util.*;
import org.apache.juneau.*;
import org.apache.juneau.http.*;
import org.apache.juneau.parser.*;
/**
* Builder class for building XML parsers.
*/
public class XmlParserBuilder extends ParserBuilder {
/**
* Constructor, default settings.
*/
public XmlParserBuilder() {
super();
}
/**
* Constructor.
*
* @param propertyStore The initial configuration settings for this builder.
*/
public XmlParserBuilder(PropertyStore propertyStore) {
super(propertyStore);
}
@Override /* CoreObjectBuilder */
public XmlParser build() {
return new XmlParser(propertyStore);
}
//--------------------------------------------------------------------------------
// Properties
//--------------------------------------------------------------------------------
/**
* Configuration property: Enable validation.
*
*
* - Name:
"XmlParserBuilder.validating"
* - Data type:
Boolean
* - Default:
false
* - Session-overridable:
true
*
*
*
* If true , XML document will be validated.
* See {@link XMLInputFactory#IS_VALIDATING} for more info.
*
*
* If true , string values will be trimmed of whitespace using {@link String#trim()} before being added to
* the POJO.
*
*
Notes:
*
* - This is equivalent to calling
property(XML_validating , value)
.
*
*
* @param value The new value for this property.
* @return This object (for method chaining).
* @see XmlParser#XML_validating
*/
public XmlParserBuilder validating(boolean value) {
return property(XML_validating, value);
}
/**
* Configuration property: XML reporter.
*
*
* - Name:
"XmlParserBuilder.reporter"
* - Data type: {@link XMLReporter}
*
- Default:
null
* - Session-overridable:
true
*
*
*
* Associates an {@link XMLReporter} with this parser.
*
*
Notes:
*
* - Reporters are not copied to new parsers during a clone.
*
*
*
* If true , string values will be trimmed of whitespace using {@link String#trim()} before being added to
* the POJO.
*
*
Notes:
*
* - This is equivalent to calling
property(XML_reporter , value)
.
*
*
* @param value The new value for this property.
* @return This object (for method chaining).
* @see XmlParser#XML_reporter
*/
public XmlParserBuilder reporter(XMLReporter value) {
return property(XML_reporter, value);
}
/**
* Configuration property: XML resolver.
*
*
* - Name:
"XmlParserBuilder.resolver"
* - Data type: {@link XMLResolver}
*
- Default:
null
* - Session-overridable:
true
*
*
*
* Associates an {@link XMLResolver} with this parser.
*
*
* If true , string values will be trimmed of whitespace using {@link String#trim()} before being added to
* the POJO.
*
*
Notes:
*
* - This is equivalent to calling
property(XML_resolver , value)
.
*
*
* @param value The new value for this property.
* @return This object (for method chaining).
* @see XmlParser#XML_resolver
*/
public XmlParserBuilder resolver(XMLResolver value) {
return property(XML_resolver, value);
}
/**
* Configuration property: XML event allocator.
*
*
* - Name:
"XmlParserBuilder.eventAllocator"
* - Data type: {@link XMLEventAllocator}
*
- Default:
null
* - Session-overridable:
true
*
*
*
* Associates an {@link XMLEventAllocator} with this parser.
*
*
* If true , string values will be trimmed of whitespace using {@link String#trim()} before being added to
* the POJO.
*
*
Notes:
*
* - This is equivalent to calling
property(XML_eventAllocator , value)
.
*
*
* @param value The new value for this property.
* @return This object (for method chaining).
* @see XmlParser#XML_eventAllocator
*/
public XmlParserBuilder eventAllocator(XMLEventAllocator value) {
return property(XML_eventAllocator, value);
}
/**
* Configuration property: Preserve root element during generalized parsing.
*
*
* - Name:
"XmlParserBuilder.preserveRootElement"
* - Data type:
Boolean
* - Default:
false
* - Session-overridable:
true
*
*
*
* If true , when parsing into a generic {@link ObjectMap}, the map will contain a single entry whose key is
* the root element name.
*
* Example:
*
*
* XML
* ObjectMap.toString(), preserveRootElement==false
* ObjectMap.toString(), preserveRootElement==true
*
*
* <root><a> foobar</a></root>
* { a:'foobar' }
* { root: { a:'foobar' }}
*
*
*
* Notes:
*
* - This is equivalent to calling
property(XML_preserveRootElement , value)
.
*
*
* @param value The new value for this property.
* @return This object (for method chaining).
* @see XmlParser#XML_preserveRootElement
*/
public XmlParserBuilder preserveRootElement(boolean value) {
return property(XML_preserveRootElement, value);
}
@Override /* ParserBuilder */
public XmlParserBuilder trimStrings(boolean value) {
super.trimStrings(value);
return this;
}
@Override /* ParserBuilder */
public XmlParserBuilder strict(boolean value) {
super.strict(value);
return this;
}
@Override /* ParserBuilder */
public XmlParserBuilder strict() {
super.strict();
return this;
}
@Override /* ParserBuilder */
public XmlParserBuilder inputStreamCharset(String value) {
super.inputStreamCharset(value);
return this;
}
@Override /* ParserBuilder */
public XmlParserBuilder fileCharset(String value) {
super.fileCharset(value);
return this;
}
@Override /* ParserBuilder */
public XmlParserBuilder listener(Class extends ParserListener> value) {
super.listener(value);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder beansRequireDefaultConstructor(boolean value) {
super.beansRequireDefaultConstructor(value);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder beansRequireSerializable(boolean value) {
super.beansRequireSerializable(value);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder beansRequireSettersForGetters(boolean value) {
super.beansRequireSettersForGetters(value);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder beansRequireSomeProperties(boolean value) {
super.beansRequireSomeProperties(value);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder beanMapPutReturnsOldValue(boolean value) {
super.beanMapPutReturnsOldValue(value);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder beanConstructorVisibility(Visibility value) {
super.beanConstructorVisibility(value);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder beanClassVisibility(Visibility value) {
super.beanClassVisibility(value);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder beanFieldVisibility(Visibility value) {
super.beanFieldVisibility(value);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder methodVisibility(Visibility value) {
super.methodVisibility(value);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder useJavaBeanIntrospector(boolean value) {
super.useJavaBeanIntrospector(value);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder useInterfaceProxies(boolean value) {
super.useInterfaceProxies(value);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder ignoreUnknownBeanProperties(boolean value) {
super.ignoreUnknownBeanProperties(value);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder ignoreUnknownNullBeanProperties(boolean value) {
super.ignoreUnknownNullBeanProperties(value);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder ignorePropertiesWithoutSetters(boolean value) {
super.ignorePropertiesWithoutSetters(value);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder ignoreInvocationExceptionsOnGetters(boolean value) {
super.ignoreInvocationExceptionsOnGetters(value);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder ignoreInvocationExceptionsOnSetters(boolean value) {
super.ignoreInvocationExceptionsOnSetters(value);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder sortProperties(boolean value) {
super.sortProperties(value);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder notBeanPackages(String...values) {
super.notBeanPackages(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder notBeanPackages(Collection values) {
super.notBeanPackages(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder setNotBeanPackages(String...values) {
super.setNotBeanPackages(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder setNotBeanPackages(Collection values) {
super.setNotBeanPackages(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder removeNotBeanPackages(String...values) {
super.removeNotBeanPackages(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder removeNotBeanPackages(Collection values) {
super.removeNotBeanPackages(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder notBeanClasses(Class>...values) {
super.notBeanClasses(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder notBeanClasses(Collection> values) {
super.notBeanClasses(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder setNotBeanClasses(Class>...values) {
super.setNotBeanClasses(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder setNotBeanClasses(Collection> values) {
super.setNotBeanClasses(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder removeNotBeanClasses(Class>...values) {
super.removeNotBeanClasses(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder removeNotBeanClasses(Collection> values) {
super.removeNotBeanClasses(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder beanFilters(Class>...values) {
super.beanFilters(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder beanFilters(Collection> values) {
super.beanFilters(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder setBeanFilters(Class>...values) {
super.setBeanFilters(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder setBeanFilters(Collection> values) {
super.setBeanFilters(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder removeBeanFilters(Class>...values) {
super.removeBeanFilters(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder removeBeanFilters(Collection> values) {
super.removeBeanFilters(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder pojoSwaps(Class>...values) {
super.pojoSwaps(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder pojoSwaps(Collection> values) {
super.pojoSwaps(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder setPojoSwaps(Class>...values) {
super.setPojoSwaps(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder setPojoSwaps(Collection> values) {
super.setPojoSwaps(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder removePojoSwaps(Class>...values) {
super.removePojoSwaps(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder removePojoSwaps(Collection> values) {
super.removePojoSwaps(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder implClasses(Map,Class>> values) {
super.implClasses(values);
return this;
}
@Override /* CoreObjectBuilder */
public CoreObjectBuilder implClass(Class interfaceClass, Class extends T> implClass) {
super.implClass(interfaceClass, implClass);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder beanDictionary(Class>...values) {
super.beanDictionary(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder beanDictionary(Collection> values) {
super.beanDictionary(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder setBeanDictionary(Class>...values) {
super.setBeanDictionary(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder setBeanDictionary(Collection> values) {
super.setBeanDictionary(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder removeFromBeanDictionary(Class>...values) {
super.removeFromBeanDictionary(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder removeFromBeanDictionary(Collection> values) {
super.removeFromBeanDictionary(values);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder beanTypePropertyName(String value) {
super.beanTypePropertyName(value);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder defaultParser(Class> value) {
super.defaultParser(value);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder locale(Locale value) {
super.locale(value);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder timeZone(TimeZone value) {
super.timeZone(value);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder mediaType(MediaType value) {
super.mediaType(value);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder debug() {
super.debug();
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder property(String name, Object value) {
super.property(name, value);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder properties(Map properties) {
super.properties(properties);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder addToProperty(String name, Object value) {
super.addToProperty(name, value);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder putToProperty(String name, Object key, Object value) {
super.putToProperty(name, key, value);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder putToProperty(String name, Object value) {
super.putToProperty(name, value);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder removeFromProperty(String name, Object value) {
super.removeFromProperty(name, value);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder classLoader(ClassLoader classLoader) {
super.classLoader(classLoader);
return this;
}
@Override /* CoreObjectBuilder */
public XmlParserBuilder apply(PropertyStore copyFrom) {
super.apply(copyFrom);
return this;
}
}