Package org.beanio.stream.xml
Class XmlParserConfiguration
- java.lang.Object
-
- org.beanio.stream.xml.XmlParserConfiguration
-
- All Implemented Interfaces:
java.lang.Cloneable
- Direct Known Subclasses:
XmlRecordParserFactory
public class XmlParserConfiguration extends java.lang.Object implements java.lang.CloneableStores configuration settings for parsing XML formatted streams.By default, indentation is disabled and an XML header will be written to an output stream.
- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor Description XmlParserConfiguration()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddNamespace(java.lang.String prefix, java.lang.String uri)Adds a namespace to be set on the root element.protected XmlParserConfigurationclone()java.lang.StringgetEncoding()Returns the XML character encoding to include in the document header.intgetIndentation()Returns the number of spaces to indent each level of XML, or-1if indentation is disabled.java.lang.StringgetLineSeparator()Returns the text used to terminate a line when indentation is enabled.java.util.Map<java.lang.String,java.lang.String>getNamespaceMap()Returns a map of namespace URI's to prefixes to be set on the root element.java.lang.StringgetVersion()Returns the XML version to include in the document header.booleanisIndentationEnabled()Returns whether XML output will be indented.booleanisSuppressHeader()Returns whether the XML header is suppressed.voidsetEncoding(java.lang.String encoding)Sets the XML character encoding to include in the document header.voidsetIndentation(int indentation)Enables and sets the indentation level in spaces.voidsetLineSeparator(java.lang.String lineSeparator)Sets the text used to terminate a line when indentation is enabled.voidsetNamespaces(java.lang.String list)Sets the list of namespaces to be set on the root element.voidsetSuppressHeader(boolean suppressHeader)Sets whether the XML header is suppressed.voidsetVersion(java.lang.String version)Sets the XML version to include in the document header.
-
-
-
Method Detail
-
getIndentation
public int getIndentation()
Returns the number of spaces to indent each level of XML, or-1if indentation is disabled.- Returns:
- the number of spaces to indent each level of XML,
or
-1to disable indentation
-
setIndentation
public void setIndentation(int indentation)
Enables and sets the indentation level in spaces. If set to-1(the default value), indentation is disabled.- Parameters:
indentation- the number of spaces to indent each level of XML, or-1to disable indentation
-
isIndentationEnabled
public boolean isIndentationEnabled()
Returns whether XML output will be indented.- Returns:
trueif indentation is enabled
-
getLineSeparator
public java.lang.String getLineSeparator()
Returns the text used to terminate a line when indentation is enabled. When set tonull(the default), the line separator is set to the value of theline.separatorsystem property.- Returns:
- the line separation text
-
setLineSeparator
public void setLineSeparator(java.lang.String lineSeparator)
Sets the text used to terminate a line when indentation is enabled. When set tonull(the default), the line separator is set to the value of theline.separatorsystem property.- Parameters:
lineSeparator- the line separation text
-
isSuppressHeader
public boolean isSuppressHeader()
Returns whether the XML header is suppressed. Defaults tofalse.- Returns:
trueif the XML header is suppressed
-
setSuppressHeader
public void setSuppressHeader(boolean suppressHeader)
Sets whether the XML header is suppressed.- Parameters:
suppressHeader-trueto suppress the XML header
-
getVersion
public java.lang.String getVersion()
Returns the XML version to include in the document header.- Returns:
- the XML version
-
setVersion
public void setVersion(java.lang.String version)
Sets the XML version to include in the document header. Defaults to1.0. May not be set tonull.- Parameters:
version- the XML version
-
getEncoding
public java.lang.String getEncoding()
Returns the XML character encoding to include in the document header.- Returns:
- the XML character encoding
-
setEncoding
public void setEncoding(java.lang.String encoding)
Sets the XML character encoding to include in the document header. Defaults to 'utf-8'. If set tonullor empty string the document header will not include the encoding setting.- Parameters:
encoding- the XML character encoding
-
addNamespace
public void addNamespace(java.lang.String prefix, java.lang.String uri)Adds a namespace to be set on the root element.- Parameters:
prefix- the namespace prefixuri- the namespace URI
-
setNamespaces
public void setNamespaces(java.lang.String list)
Sets the list of namespaces to be set on the root element. The list should be formatted as a space delimited list of alternating prefixes and uri's. For example,setNamespaces("xsd http://www.w3.org/2001/XMLSchema b http://www.beanio.org/2011/01");- Parameters:
list- the space delimited list of namespaces
-
getNamespaceMap
public java.util.Map<java.lang.String,java.lang.String> getNamespaceMap()
Returns a map of namespace URI's to prefixes to be set on the root element.- Returns:
- the map of namespace prefixes to URI's
-
clone
protected XmlParserConfiguration clone()
- Overrides:
clonein classjava.lang.Object
-
-