BeanIO 1.2.3

org.beanio.stream.xml
Class XmlWriterConfiguration

java.lang.Object
  extended by org.beanio.stream.xml.XmlWriterConfiguration
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
XmlWriterFactory

public class XmlWriterConfiguration
extends Object
implements Cloneable

Stores XML writer configuration settings.

By default, indentation is disabled and no XML header will be written to an output stream.

Since:
1.1
Author:
Kevin Seim
See Also:
XmlWriter

Constructor Summary
XmlWriterConfiguration()
          Constructs a new XmlWriterConfiguration.
 
Method Summary
 void addNamespace(String prefix, String uri)
          Adds a namespace to be set on the root element.
protected  XmlWriterConfiguration clone()
           
 String getEncoding()
          Returns the XML character encoding to include in the document header.
 int getIndentation()
          Returns the number of spaces to indent each level of XML, or -1 if indentation is disabled.
 String getLineSeparator()
          Returns the text used to terminate a line when indentation is enabled.
 Map<String,String> getNamespaceMap()
          Returns a map of namespace URI's to prefixes to be set on the root element.
 String getVersion()
          Returns the XML version to include in the document header.
 boolean isIndentationEnabled()
          Returns whether XML output will be indented.
 boolean isSuppressHeader()
          Returns whether the XML header is suppressed.
 void setEncoding(String encoding)
          Sets the XML character encoding to include in the document header.
 void setIndentation(int indentation)
          Enables and sets the indentation level in spaces.
 void setLineSeparator(String lineSeparator)
          Sets the text used to terminate a line when indentation is enabled.
 void setNamespaces(String list)
          Sets the list of namespaces to be set on the root element.
 void setSuppressHeader(boolean suppressHeader)
          Sets whether the XML header is suppressed.
 void setVersion(String version)
          Sets the XML version to include in the document header.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlWriterConfiguration

public XmlWriterConfiguration()
Constructs a new XmlWriterConfiguration.

Method Detail

getIndentation

public int getIndentation()
Returns the number of spaces to indent each level of XML, or -1 if indentation is disabled.

Returns:
the number of spaces to indent each level of XML, or -1 to 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 -1 to disable indentation

isIndentationEnabled

public boolean isIndentationEnabled()
Returns whether XML output will be indented.

Returns:
true if indentation is enabled

getLineSeparator

public String getLineSeparator()
Returns the text used to terminate a line when indentation is enabled. When set to null (the default), the line separator is set to the value of the line.separator system property.

Returns:
the line separation text

setLineSeparator

public void setLineSeparator(String lineSeparator)
Sets the text used to terminate a line when indentation is enabled. When set to null (the default), the line separator is set to the value of the line.separator system property.

Parameters:
lineSeparator - the line separation text

isSuppressHeader

public boolean isSuppressHeader()
Returns whether the XML header is suppressed. Defaults to false.

Returns:
true if the XML header is suppressed

setSuppressHeader

public void setSuppressHeader(boolean suppressHeader)
Sets whether the XML header is suppressed.

Parameters:
suppressHeader - true to suppress the XML header

getVersion

public String getVersion()
Returns the XML version to include in the document header.

Returns:
the XML version

setVersion

public void setVersion(String version)
Sets the XML version to include in the document header. Defaults to 1.0. May not be set to null.

Parameters:
version - the XML version

getEncoding

public String getEncoding()
Returns the XML character encoding to include in the document header.

Returns:
the XML character encoding

setEncoding

public void setEncoding(String encoding)
Sets the XML character encoding to include in the document header. Defaults to 'utf-8'. If set to null or empty string the document header will not include the encoding setting.

Parameters:
encoding - the XML character encoding

addNamespace

public void addNamespace(String prefix,
                         String uri)
Adds a namespace to be set on the root element.

Parameters:
prefix - the namespace prefix
uri - the namespace URI

setNamespaces

public void setNamespaces(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 Map<String,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 XmlWriterConfiguration clone()
Overrides:
clone in class Object

BeanIO 1.2.3

Copyright © 2010-2012 Kevin Seim