global.sandbox.xmlutilities
Class OutputFormat

java.lang.Object
  extended by global.sandbox.xmlutilities.OutputFormat
All Implemented Interfaces:
Serializable

public class OutputFormat
extends Object
implements Serializable

Convenient harness for configuration of Transformers' output intent. This class supports the following keys:

Version:
1.2
Author:
Petr Hadraba
See Also:
Serialized Form

Nested Class Summary
static class OutputFormat.Boolean
          Represents Boolean value with appropriate value expected by Transformer.
static class OutputFormat.Builder
          Builder for declarative construction of OutputFormat.
private static interface OutputFormat.ConfigurationValue
          Convenient interface for getting rendered codes.
static class OutputFormat.OutputMethod
          Typed representation of output method with appropriate and expected values by Transformer.
 
Field Summary
private  List<String> cdataSectionElements
          CDATA section element list.
private  Map<String,String> customProperties
          Custom properties.
private  String doctypePublic
          DOCTYPE PUBLIC.
private  String doctypeSystem
          DOCTYPE SYSTEM.
private  String encoding
          encoding.
static String HTML_VERSION_4_0
          Default version for HTML output method.
private  OutputFormat.Boolean indent
          Indent flag.
private  String mediaType
          Media type.
private  OutputFormat.OutputMethod method
          output method.
private  OutputFormat.Boolean omitXmlDeclaration
          omit XML Declaration flag.
private static long serialVersionUID
           
private  OutputFormat.Boolean standalone
          standalone flag.
private static List<String> SUPPORTED_KEYS
          List of supported keys by this class.
private  String version
          version.
static String XML_VERSION_1_0
          Default version for XML output method.
 
Constructor Summary
OutputFormat()
           
 
Method Summary
 void addCdataSectionElement(String elementName)
          Adds qualified element name into CDATA section element list.
 void addCustomProperty(String key, String value)
          Adds specified key-value property.
private static void addPropertyIfDefined(Properties result, String key, OutputFormat.ConfigurationValue value)
          Adds property if value is not null.
private static void addPropertyIfDefined(Properties result, String key, String value)
          Adds property if value is not null.
 List<String> getCdataSectionElements()
          Returns list of CDATA section elements.
 Map<String,String> getCustomProperties()
          Returns custom properties.
 String getDoctypePublic()
          Returns DOCTYPE PUBLIC.
 String getDoctypeSystem()
          Returns DOCTYPE SYSTEM.
 String getEncoding()
          Returns encoding.
 OutputFormat.Boolean getIndent()
          Returns indent.
 String getMediaType()
          Returns media type.
 OutputFormat.OutputMethod getMethod()
          Returns output method.
 OutputFormat.Boolean getOmitXmlDeclaration()
          Returns omit XML declaration flag.
 OutputFormat.Boolean getStandalone()
          Returns standalone.
 String getVersion()
          Returns version.
static OutputFormat.Builder newCustomMethodBuilder(String method)
          Creates builder for custom method.
static OutputFormat.Builder newHtmlMethodBuilder()
          Creates builder for HTML method intent.
static OutputFormat.Builder newTextMethodBuilder()
          Creates builder for Text method intent.
static OutputFormat.Builder newXmlMethodBuilder()
          Creates builder for XML method intent.
private static String renderCdataSectionElementList(List<String> elements)
          Renders list of CDATA section elements into property value text.
 void setDoctypePublic(String doctypePublic)
          Sets DOCTYPE PUBLIC.
 void setDoctypeSystem(String doctypeSystem)
          Sets DOCTYPE SYSTEM.
 void setEncoding(String encoding)
          Sets encoding.
 void setIndent(OutputFormat.Boolean indent)
          Sets indent flag.
 void setMediaType(String mediaType)
          Sets media type.
 void setMethod(OutputFormat.OutputMethod method)
          Sets output method.
 void setOmitXmlDeclaration(OutputFormat.Boolean omitXmlDeclaration)
          Sets omit XML declaration flag.
 void setStandalone(OutputFormat.Boolean standalone)
          Sets standalone flag.
 void setVersion(String version)
          Sets version.
 Properties toTransformerOutputProperties()
          Renders this class into Properties ready to be used by setOutputProperties(java.util.Properties).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

XML_VERSION_1_0

public static final String XML_VERSION_1_0
Default version for XML output method.


HTML_VERSION_4_0

public static final String HTML_VERSION_4_0
Default version for HTML output method.


SUPPORTED_KEYS

private static final List<String> SUPPORTED_KEYS
List of supported keys by this class.


method

private OutputFormat.OutputMethod method
output method.


version

private String version
version.


encoding

private String encoding
encoding.


omitXmlDeclaration

private OutputFormat.Boolean omitXmlDeclaration
omit XML Declaration flag.


standalone

private OutputFormat.Boolean standalone
standalone flag.


doctypePublic

private String doctypePublic
DOCTYPE PUBLIC.


doctypeSystem

private String doctypeSystem
DOCTYPE SYSTEM.


cdataSectionElements

private final List<String> cdataSectionElements
CDATA section element list.


indent

private OutputFormat.Boolean indent
Indent flag.


mediaType

private String mediaType
Media type.


customProperties

private final Map<String,String> customProperties
Custom properties.

Constructor Detail

OutputFormat

public OutputFormat()
Method Detail

newXmlMethodBuilder

public static OutputFormat.Builder newXmlMethodBuilder()
Creates builder for XML method intent.

Returns:
Builder

newHtmlMethodBuilder

public static OutputFormat.Builder newHtmlMethodBuilder()
Creates builder for HTML method intent.

Returns:
Builder

newTextMethodBuilder

public static OutputFormat.Builder newTextMethodBuilder()
Creates builder for Text method intent.

Returns:
Builder

newCustomMethodBuilder

public static OutputFormat.Builder newCustomMethodBuilder(String method)
Creates builder for custom method.

Parameters:
method - mandatory name of the custom method
Returns:
Builder

toTransformerOutputProperties

public Properties toTransformerOutputProperties()
Renders this class into Properties ready to be used by setOutputProperties(java.util.Properties).

Returns:
Properties

addPropertyIfDefined

private static void addPropertyIfDefined(Properties result,
                                         String key,
                                         String value)
Adds property if value is not null.

Parameters:
result - target map
key - key
value - value

addPropertyIfDefined

private static void addPropertyIfDefined(Properties result,
                                         String key,
                                         OutputFormat.ConfigurationValue value)
Adds property if value is not null.

Parameters:
result - target map
key - key
value - value

renderCdataSectionElementList

private static String renderCdataSectionElementList(List<String> elements)
Renders list of CDATA section elements into property value text.

Parameters:
elements - list of CDATA section elements
Returns:
text

setMethod

public void setMethod(OutputFormat.OutputMethod method)
Sets output method.

Parameters:
method - method

setVersion

public void setVersion(String version)
Sets version.

Parameters:
version - version string

setEncoding

public void setEncoding(String encoding)
Sets encoding.

Parameters:
encoding - encoding name

setOmitXmlDeclaration

public void setOmitXmlDeclaration(OutputFormat.Boolean omitXmlDeclaration)
Sets omit XML declaration flag.

Parameters:
omitXmlDeclaration - state

setStandalone

public void setStandalone(OutputFormat.Boolean standalone)
Sets standalone flag.

Parameters:
standalone - state

setDoctypePublic

public void setDoctypePublic(String doctypePublic)
Sets DOCTYPE PUBLIC.

Parameters:
doctypePublic - value

setDoctypeSystem

public void setDoctypeSystem(String doctypeSystem)
Sets DOCTYPE SYSTEM.

Parameters:
doctypeSystem - value

setIndent

public void setIndent(OutputFormat.Boolean indent)
Sets indent flag.

Parameters:
indent - state

setMediaType

public void setMediaType(String mediaType)
Sets media type.

Parameters:
mediaType - media type

addCdataSectionElement

public void addCdataSectionElement(String elementName)
Adds qualified element name into CDATA section element list. The element should not exist in the list already.

Parameters:
elementName - element to add

addCustomProperty

public void addCustomProperty(String key,
                              String value)
Adds specified key-value property. The property should not be one of the properties directly supported by this class.

Parameters:
key - key
value - value

getMethod

public OutputFormat.OutputMethod getMethod()
Returns output method.

Returns:
output method

getVersion

public String getVersion()
Returns version.

Returns:
version

getEncoding

public String getEncoding()
Returns encoding.

Returns:
encoding

getOmitXmlDeclaration

public OutputFormat.Boolean getOmitXmlDeclaration()
Returns omit XML declaration flag.

Returns:
omit XML declaration flag

getStandalone

public OutputFormat.Boolean getStandalone()
Returns standalone.

Returns:
standalone

getDoctypePublic

public String getDoctypePublic()
Returns DOCTYPE PUBLIC.

Returns:
DOCTYPE PUBLIC

getDoctypeSystem

public String getDoctypeSystem()
Returns DOCTYPE SYSTEM.

Returns:
DOCTYPE SYSTEM

getCdataSectionElements

public List<String> getCdataSectionElements()
Returns list of CDATA section elements.

Returns:
list of CDATA section elements

getIndent

public OutputFormat.Boolean getIndent()
Returns indent.

Returns:
indent

getMediaType

public String getMediaType()
Returns media type.

Returns:
media type

getCustomProperties

public Map<String,String> getCustomProperties()
Returns custom properties.

Returns:
custom properties


Copyright © 2006–2017. All rights reserved.