global.sandbox.xmlutilities
Class OutputFormat.Builder

java.lang.Object
  extended by global.sandbox.xmlutilities.OutputFormat.Builder
Enclosing class:
OutputFormat

public static final class OutputFormat.Builder
extends Object

Builder for declarative construction of OutputFormat.

Version:
1.2
Author:
Petr Hadraba

Field Summary
private  OutputFormat outputFormat
          Under-layering output format.
 
Constructor Summary
private OutputFormat.Builder(OutputFormat.OutputMethod method, String customCode)
          Creates new Builder with valid output method.
 
Method Summary
 OutputFormat.Builder addCdataSectionElement(Element element)
          Adds specified Element into CDATA section element list.
 OutputFormat.Builder addCdataSectionElement(String elementName)
          Adds element name as is into CDATA section element list.
 OutputFormat.Builder addCdataSectionElement(String namespaceUri, String localName)
          Adds specified local name with optional name space URI into CDATA section element list.
 OutputFormat.Builder asStandalone()
          Sets standalone flag.
 OutputFormat build()
          Returns under-layering Output Format object.
 Properties buildToTransformerOutputProperties()
          Creates Properties ready to use in setOutputProperties(java.util.Properties).
 OutputFormat.Builder dontOmitXmlDeclaration()
          Sets omit XML Declaration flag to no.
 OutputFormat.Builder indent()
          Sets indent flag.
 OutputFormat.Builder omitXmlDeclaration()
          Sets omit XML Declaration flag to yes.
 OutputFormat.Builder setDoctypePublic(String doctype)
          Sets DOCTYPE PUBLIC
 OutputFormat.Builder setDoctypeSystem(String doctype)
          Sets DOCTYPE SYSTEM.
 OutputFormat.Builder setEncoding(Charset charset)
          Sets encoding from specified Charset.
 OutputFormat.Builder setEncoding(String encoding)
          Sets encoding.
 OutputFormat.Builder setIndent(OutputFormat.Boolean state)
          Sets indent flag.
 OutputFormat.Builder setMediaType(String mediaType)
          Sets media type.
 OutputFormat.Builder setOmitXmlDeclaration(OutputFormat.Boolean state)
          Sets omit XML Declaration flag.
 OutputFormat.Builder setStandalone(OutputFormat.Boolean state)
          Sets standalone flag.
 OutputFormat.Builder setVersion(String version)
          Sets version.
 OutputFormat.Builder withCustomProperty(String key, String value)
          Adds custom property which does not exist already and is not one of the properties managed by this builder.
 OutputFormat.Builder withDefaultVersion()
          Sets default version for XML and HTML output method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

outputFormat

private final OutputFormat outputFormat
Under-layering output format.

Constructor Detail

OutputFormat.Builder

private OutputFormat.Builder(OutputFormat.OutputMethod method,
                             String customCode)
Creates new Builder with valid output method.

Parameters:
method - method
customCode - custom code for CUSTOM
Method Detail

build

public OutputFormat build()
Returns under-layering Output Format object.

Returns:
output format

buildToTransformerOutputProperties

public Properties buildToTransformerOutputProperties()
Creates Properties ready to use in setOutputProperties(java.util.Properties).

Returns:
Properties

setVersion

public OutputFormat.Builder setVersion(String version)
Sets version.

Parameters:
version - text
Returns:
Builder

withDefaultVersion

public OutputFormat.Builder withDefaultVersion()
Sets default version for XML and HTML output method.

Returns:
Builder

setEncoding

public OutputFormat.Builder setEncoding(String encoding)
Sets encoding.

Parameters:
encoding - text
Returns:
Builder

setEncoding

public OutputFormat.Builder setEncoding(Charset charset)
Sets encoding from specified Charset.

Parameters:
charset - Charset to use
Returns:
Builder

setOmitXmlDeclaration

public OutputFormat.Builder setOmitXmlDeclaration(OutputFormat.Boolean state)
Sets omit XML Declaration flag.

Parameters:
state - new state
Returns:
Builder

omitXmlDeclaration

public OutputFormat.Builder omitXmlDeclaration()
Sets omit XML Declaration flag to yes.

Returns:
Builder

dontOmitXmlDeclaration

public OutputFormat.Builder dontOmitXmlDeclaration()
Sets omit XML Declaration flag to no.

Returns:
Builder

setStandalone

public OutputFormat.Builder setStandalone(OutputFormat.Boolean state)
Sets standalone flag.

Parameters:
state - new state
Returns:
Builder

asStandalone

public OutputFormat.Builder asStandalone()
Sets standalone flag.

Returns:
Builder

setDoctypePublic

public OutputFormat.Builder setDoctypePublic(String doctype)
Sets DOCTYPE PUBLIC

Parameters:
doctype - DOCTYPE PUBLIC
Returns:
Builder

setDoctypeSystem

public OutputFormat.Builder setDoctypeSystem(String doctype)
Sets DOCTYPE SYSTEM.

Parameters:
doctype - DOCTYPE SYSTEM
Returns:
Builder

addCdataSectionElement

public OutputFormat.Builder addCdataSectionElement(String elementName)
Adds element name as is into CDATA section element list.

Parameters:
elementName - name to add
Returns:
Builder

addCdataSectionElement

public OutputFormat.Builder addCdataSectionElement(String namespaceUri,
                                                   String localName)
Adds specified local name with optional name space URI into CDATA section element list.

Parameters:
namespaceUri - optional name space URI
localName - element name
Returns:
Builder

addCdataSectionElement

public OutputFormat.Builder addCdataSectionElement(Element element)
Adds specified Element into CDATA section element list. The element is resolved to qualified name.

Parameters:
element - element to add
Returns:
Builder

setIndent

public OutputFormat.Builder setIndent(OutputFormat.Boolean state)
Sets indent flag.

Parameters:
state - state
Returns:
Builder

indent

public OutputFormat.Builder indent()
Sets indent flag.

Returns:
Builder

setMediaType

public OutputFormat.Builder setMediaType(String mediaType)
Sets media type.

Parameters:
mediaType - media type
Returns:
Builder

withCustomProperty

public OutputFormat.Builder withCustomProperty(String key,
                                               String value)
Adds custom property which does not exist already and is not one of the properties managed by this builder.

Parameters:
key - key
value - value
Returns:
Builder


Copyright © 2006–2017. All rights reserved.