OutputFormat (Other Classes)
Date: 2016-02-03

org.apache.xml.serialize

## Class OutputFormat

- java.lang.Object
- - org.apache.xml.serialize.OutputFormat

- Deprecated.
  This class was deprecated in Xerces 2.9.0. It is recommended that new applications use the DOM Level 3 LSSerializer or JAXP's Transformation API for XML (TrAX) for serializing XML and HTML. See the Xerces documentation for more information.

      public class OutputFormat
      extends java.lang.Object

  Specifies an output format to control the serializer. Based on the XSLT specification for output format, plus additional parameters. Used to select the suitable serializer and determine how the document should be formatted on output.

  The two interesting constructors are:

  - `OutputFormat(String,String,boolean)` creates a format for the specified method (XML, HTML, Text, etc), encoding and indentation
  - `OutputFormat(Document,String,boolean)` creates a format compatible with the document type (XML, HTML, Text, etc), encoding and indentation
  Version:
    $Revision: 476048 $ $Date: 2006-11-16 23:32:47 -0500 (Thu, 16 Nov 2006) $
  Author:
    Assaf Arkin Keith Visco
  See Also:
    `Serializer`, `Method`, `LineSeparator`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `OutputFormat.Defaults` Deprecated. This class was deprecated in Xerces 2.9.0. It is recommended that new applications use the DOM Level 3 LSSerializer or JAXP's Transformation API for XML (TrAX) for serializing XML and HTML. See the Xerces documentation for more information.
    `static class` | `OutputFormat.DTD` Deprecated. This class was deprecated in Xerces 2.9.0. It is recommended that new applications use the DOM Level 3 LSSerializer or JAXP's Transformation API for XML (TrAX) for serializing XML and HTML. See the Xerces documentation for more information.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `OutputFormat()` Deprecated. Constructs a new output format with the default values.
    `OutputFormat(org.w3c.dom.Document doc)` Deprecated. Constructs a new output format with the proper method, document type identifiers and media type for the specified document.
    `OutputFormat(org.w3c.dom.Document doc, java.lang.String encoding, boolean indenting)` Deprecated. Constructs a new output format with the proper method, document type identifiers and media type for the specified document, and with the specified encoding.
    `OutputFormat(java.lang.String method, java.lang.String encoding, boolean indenting)` Deprecated. Constructs a new output format with the default values for the specified method and encoding.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String[]` | `getCDataElements()` Deprecated. Returns a list of all the elements whose text node children should be output as CDATA, or null if no such elements were specified.
    `java.lang.String` | `getDoctypePublic()` Deprecated. Returns the specified document type public identifier, or null.
    `java.lang.String` | `getDoctypeSystem()` Deprecated. Returns the specified document type system identifier, or null.
    `java.lang.String` | `getEncoding()` Deprecated. Returns the specified encoding.
    `EncodingInfo` | `getEncodingInfo()` Deprecated. Returns an `EncodingInfo` instance for the encoding.
    `int` | `getIndent()` Deprecated. Returns the indentation specified.
    `boolean` | `getIndenting()` Deprecated. Returns true if indentation was specified.
    `char` | `getLastPrintable()` Deprecated. Returns the last printable character based on the selected encoding.
    `java.lang.String` | `getLineSeparator()` Deprecated. Returns a specific line separator to use.
    `int` | `getLineWidth()` Deprecated. Return the selected line width for breaking up long lines.
    `java.lang.String` | `getMediaType()` Deprecated. Returns the specified media type, or null.
    `java.lang.String` | `getMethod()` Deprecated. Returns the method specified for this output format.
    `java.lang.String[]` | `getNonEscapingElements()` Deprecated. Returns a list of all the elements whose text node children should be output unescaped (no character references), or null if no such elements were specified.
    `boolean` | `getOmitComments()` Deprecated. Returns true if comments should be ommited.
    `boolean` | `getOmitDocumentType()` Deprecated. Returns true if the DOCTYPE declaration should be ommited.
    `boolean` | `getOmitXMLDeclaration()` Deprecated. Returns true if the XML document declaration should be ommited.
    `boolean` | `getPreserveEmptyAttributes()` Deprecated. Returns the preserveEmptyAttribute flag.
    `boolean` | `getPreserveSpace()` Deprecated. Returns true if the default behavior for this format is to preserve spaces.
    `boolean` | `getStandalone()` Deprecated. Returns true if the document type is standalone.
    `java.lang.String` | `getVersion()` Deprecated. Returns the version for this output method.
    `boolean` | `isCDataElement(java.lang.String tagName)` Deprecated. Returns true if the text node children of the given elements should be output as CDATA.
    `boolean` | `isNonEscapingElement(java.lang.String tagName)` Deprecated. Returns true if the text node children of the given elements should be output unescaped.
    `boolean` | `setAllowJavaNames()` Deprecated. Returns whether java encoding names are permitted
    `void` | `setAllowJavaNames(boolean allow)` Deprecated. Sets whether java encoding names are permitted
    `void` | `setCDataElements(java.lang.String[] cdataElements)` Deprecated. Sets the list of elements for which text node children should be output as CDATA.
    `void` | `setDoctype(java.lang.String publicId, java.lang.String systemId)` Deprecated. Sets the document type public and system identifiers.
    `void` | `setEncoding(EncodingInfo encInfo)` Deprecated. Sets the encoding for this output method with an `EncodingInfo` instance.
    `void` | `setEncoding(java.lang.String encoding)` Deprecated. Sets the encoding for this output method.
    `void` | `setIndent(int indent)` Deprecated. Sets the indentation.
    `void` | `setIndenting(boolean on)` Deprecated. Sets the indentation on and off.
    `void` | `setLineSeparator(java.lang.String lineSeparator)` Deprecated. Sets the line separator.
    `void` | `setLineWidth(int lineWidth)` Deprecated. Sets the line width.
    `void` | `setMediaType(java.lang.String mediaType)` Deprecated. Sets the media type.
    `void` | `setMethod(java.lang.String method)` Deprecated. Sets the method for this output format.
    `void` | `setNonEscapingElements(java.lang.String[] nonEscapingElements)` Deprecated. Sets the list of elements for which text node children should be output unescaped (no character references).
    `void` | `setOmitComments(boolean omit)` Deprecated. Sets comment omitting on and off.
    `void` | `setOmitDocumentType(boolean omit)` Deprecated. Sets DOCTYPE declaration omitting on and off.
    `void` | `setOmitXMLDeclaration(boolean omit)` Deprecated. Sets XML declaration omitting on and off.
    `void` | `setPreserveEmptyAttributes(boolean preserve)` Deprecated. Sets the preserveEmptyAttribute flag.
    `void` | `setPreserveSpace(boolean preserve)` Deprecated. Sets space preserving as the default behavior.
    `void` | `setStandalone(boolean standalone)` Deprecated. Sets document DTD standalone.
    `void` | `setVersion(java.lang.String version)` Deprecated. Sets the version for this output method.
    `static java.lang.String` | `whichDoctypePublic(org.w3c.dom.Document doc)` Deprecated. Returns the document type public identifier specified for this document, or null.
    `static java.lang.String` | `whichDoctypeSystem(org.w3c.dom.Document doc)` Deprecated. Returns the document type system identifier specified for this document, or null.
    `static java.lang.String` | `whichMediaType(java.lang.String method)` Deprecated. Returns the suitable media format for a document output with the specified method.
    `static java.lang.String` | `whichMethod(org.w3c.dom.Document doc)` Deprecated. Determine the output method for the specified document.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### OutputFormat

          public OutputFormat()

      Deprecated.
      Constructs a new output format with the default values.

    - #### OutputFormat

          public OutputFormat(java.lang.String method,
                      java.lang.String encoding,
                      boolean indenting)

      Deprecated.
      Constructs a new output format with the default values for the specified method and encoding. If `indent` is true, the document will be pretty printed with the default indentation level and default line wrapping.
      Parameters:
        `method` - The specified output method
        `encoding` - The specified encoding
        `indenting` - True for pretty printing
      See Also:
        `setEncoding(java.lang.String)`, `setIndenting(boolean)`, `setMethod(java.lang.String)`

    - #### OutputFormat

          public OutputFormat(org.w3c.dom.Document doc)

      Deprecated.
      Constructs a new output format with the proper method, document type identifiers and media type for the specified document.
      Parameters:
        `doc` - The document to output
      See Also:
        `whichMethod(org.w3c.dom.Document)`

    - #### OutputFormat

          public OutputFormat(org.w3c.dom.Document doc,
                      java.lang.String encoding,
                      boolean indenting)

      Deprecated.
      Constructs a new output format with the proper method, document type identifiers and media type for the specified document, and with the specified encoding. If `indent` is true, the document will be pretty printed with the default indentation level and default line wrapping.
      Parameters:
        `doc` - The document to output
        `encoding` - The specified encoding
        `indenting` - True for pretty printing
      See Also:
        `setEncoding(java.lang.String)`, `setIndenting(boolean)`, `whichMethod(org.w3c.dom.Document)`

  - ### Method Detail

    - #### getMethod

          public java.lang.String getMethod()

      Deprecated.
      Returns the method specified for this output format. Typically the method will be `xml`, `html` or `text`, but it might be other values. If no method was specified, null will be returned and the most suitable method will be determined for the document by calling `whichMethod(org.w3c.dom.Document)`.
      Returns:
        The specified output method, or null

    - #### setMethod

          public void setMethod(java.lang.String method)

      Deprecated.
      Sets the method for this output format.
      Parameters:
        `method` - The output method, or null
      See Also:
        `getMethod()`

    - #### getVersion

          public java.lang.String getVersion()

      Deprecated.
      Returns the version for this output method. If no version was specified, will return null and the default version number will be used. If the serializer does not support that particular version, it should default to a supported version.
      Returns:
        The specified method version, or null

    - #### setVersion

          public void setVersion(java.lang.String version)

      Deprecated.
      Sets the version for this output method. For XML the value would be "1.0", for HTML it would be "4.0".
      Parameters:
        `version` - The output method version, or null
      See Also:
        `getVersion()`

    - #### getIndent

          public int getIndent()

      Deprecated.
      Returns the indentation specified. If no indentation was specified, zero is returned and the document should not be indented.
      Returns:
        The indentation or zero
      See Also:
        `setIndenting(boolean)`

    - #### getIndenting

          public boolean getIndenting()

      Deprecated.
      Returns true if indentation was specified.

    - #### setIndent

          public void setIndent(int indent)

      Deprecated.
      Sets the indentation. The document will not be indented if the indentation is set to zero. Calling `setIndenting(boolean)` will reset this value to zero (off) or the default (on).
      Parameters:
        `indent` - The indentation, or zero

    - #### setIndenting

          public void setIndenting(boolean on)

      Deprecated.
      Sets the indentation on and off. When set on, the default indentation level and default line wrapping is used (see `OutputFormat.Defaults.Indent` and `OutputFormat.Defaults.LineWidth`). To specify a different indentation level or line wrapping, use `setIndent(int)` and `setLineWidth(int)`.
      Parameters:
        `on` - True if indentation should be on

    - #### getEncoding

          public java.lang.String getEncoding()

      Deprecated.
      Returns the specified encoding. If no encoding was specified, the default is always "UTF-8".
      Returns:
        The encoding

    - #### setEncoding

          public void setEncoding(java.lang.String encoding)

      Deprecated.
      Sets the encoding for this output method. If no encoding was specified, the default is always "UTF-8". Make sure the encoding is compatible with the one used by the `Writer`.
      Parameters:
        `encoding` - The encoding, or null
      See Also:
        `getEncoding()`

    - #### setEncoding

          public void setEncoding(EncodingInfo encInfo)

      Deprecated.
      Sets the encoding for this output method with an `EncodingInfo` instance.

    - #### getEncodingInfo

          public EncodingInfo getEncodingInfo()
                                       throws java.io.UnsupportedEncodingException

      Deprecated.
      Returns an `EncodingInfo` instance for the encoding.
      Throws:
        `java.io.UnsupportedEncodingException`
      See Also:
        `setEncoding(java.lang.String)`

    - #### setAllowJavaNames

          public void setAllowJavaNames(boolean allow)

      Deprecated.
      Sets whether java encoding names are permitted

    - #### setAllowJavaNames

          public boolean setAllowJavaNames()

      Deprecated.
      Returns whether java encoding names are permitted

    - #### getMediaType

          public java.lang.String getMediaType()

      Deprecated.
      Returns the specified media type, or null. To determine the media type based on the document type, use `whichMediaType(java.lang.String)`.
      Returns:
        The specified media type, or null

    - #### setMediaType

          public void setMediaType(java.lang.String mediaType)

      Deprecated.
      Sets the media type.
      Parameters:
        `mediaType` - The specified media type
      See Also:
        `getMediaType()`

    - #### setDoctype

          public void setDoctype(java.lang.String publicId,
                        java.lang.String systemId)

      Deprecated.
      Sets the document type public and system identifiers. Required only if the DOM Document or SAX events do not specify the document type, and one must be present in the serialized document. Any document type specified by the DOM Document or SAX events will override these values.
      Parameters:
        `publicId` - The public identifier, or null
        `systemId` - The system identifier, or null

    - #### getDoctypePublic

          public java.lang.String getDoctypePublic()

      Deprecated.
      Returns the specified document type public identifier, or null.

    - #### getDoctypeSystem

          public java.lang.String getDoctypeSystem()

      Deprecated.
      Returns the specified document type system identifier, or null.

    - #### getOmitComments

          public boolean getOmitComments()

      Deprecated.
      Returns true if comments should be ommited. The default is false.

    - #### setOmitComments

          public void setOmitComments(boolean omit)

      Deprecated.
      Sets comment omitting on and off.
      Parameters:
        `omit` - True if comments should be ommited

    - #### getOmitDocumentType

          public boolean getOmitDocumentType()

      Deprecated.
      Returns true if the DOCTYPE declaration should be ommited. The default is false.

    - #### setOmitDocumentType

          public void setOmitDocumentType(boolean omit)

      Deprecated.
      Sets DOCTYPE declaration omitting on and off.
      Parameters:
        `omit` - True if DOCTYPE declaration should be ommited

    - #### getOmitXMLDeclaration

          public boolean getOmitXMLDeclaration()

      Deprecated.
      Returns true if the XML document declaration should be ommited. The default is false.

    - #### setOmitXMLDeclaration

          public void setOmitXMLDeclaration(boolean omit)

      Deprecated.
      Sets XML declaration omitting on and off.
      Parameters:
        `omit` - True if XML declaration should be ommited

    - #### getStandalone

          public boolean getStandalone()

      Deprecated.
      Returns true if the document type is standalone. The default is false.

    - #### setStandalone

          public void setStandalone(boolean standalone)

      Deprecated.
      Sets document DTD standalone. The public and system identifiers must be null for the document to be serialized as standalone.
      Parameters:
        `standalone` - True if document DTD is standalone

    - #### getCDataElements

          public java.lang.String[] getCDataElements()

      Deprecated.
      Returns a list of all the elements whose text node children should be output as CDATA, or null if no such elements were specified.

    - #### isCDataElement

          public boolean isCDataElement(java.lang.String tagName)

      Deprecated.
      Returns true if the text node children of the given elements should be output as CDATA.
      Parameters:
        `tagName` - The element's tag name
      Returns:
        True if should serialize as CDATA

    - #### setCDataElements

          public void setCDataElements(java.lang.String[] cdataElements)

      Deprecated.
      Sets the list of elements for which text node children should be output as CDATA.
      Parameters:
        `cdataElements` - List of CDATA element tag names

    - #### getNonEscapingElements

          public java.lang.String[] getNonEscapingElements()

      Deprecated.
      Returns a list of all the elements whose text node children should be output unescaped (no character references), or null if no such elements were specified.

    - #### isNonEscapingElement

          public boolean isNonEscapingElement(java.lang.String tagName)

      Deprecated.
      Returns true if the text node children of the given elements should be output unescaped.
      Parameters:
        `tagName` - The element's tag name
      Returns:
        True if should serialize unescaped

    - #### setNonEscapingElements

          public void setNonEscapingElements(java.lang.String[] nonEscapingElements)

      Deprecated.
      Sets the list of elements for which text node children should be output unescaped (no character references).
      Parameters:
        `nonEscapingElements` - List of unescaped element tag names

    - #### getLineSeparator

          public java.lang.String getLineSeparator()

      Deprecated.
      Returns a specific line separator to use. The default is the Web line separator (`\n`). A string is returned to support double codes (CR + LF).
      Returns:
        The specified line separator

    - #### setLineSeparator

          public void setLineSeparator(java.lang.String lineSeparator)

      Deprecated.
      Sets the line separator. The default is the Web line separator (`\n`). The machine's line separator can be obtained from the system property `line.separator`, but is only useful if the document is edited on machines of the same type. For general documents, use the Web line separator.
      Parameters:
        `lineSeparator` - The specified line separator

    - #### getPreserveSpace

          public boolean getPreserveSpace()

      Deprecated.
      Returns true if the default behavior for this format is to preserve spaces. All elements that do not specify otherwise or specify the default behavior will be formatted based on this rule. All elements that specify space preserving will always preserve space.

    - #### setPreserveSpace

          public void setPreserveSpace(boolean preserve)

      Deprecated.
      Sets space preserving as the default behavior. The default is space stripping and all elements that do not specify otherwise or use the default value will not preserve spaces.
      Parameters:
        `preserve` - True if spaces should be preserved

    - #### getLineWidth

          public int getLineWidth()

      Deprecated.
      Return the selected line width for breaking up long lines. When indenting, and only when indenting, long lines will be broken at space boundaries based on this line width. No line wrapping occurs if this value is zero.

    - #### setLineWidth

          public void setLineWidth(int lineWidth)

      Deprecated.
      Sets the line width. If zero then no line wrapping will occur. Calling `setIndenting(boolean)` will reset this value to zero (off) or the default (on).
      Parameters:
        `lineWidth` - The line width to use, zero for default
      See Also:
        `getLineWidth()`, `setIndenting(boolean)`

    - #### getPreserveEmptyAttributes

          public boolean getPreserveEmptyAttributes()

      Deprecated.
      Returns the preserveEmptyAttribute flag. If flag is false, then' attributes with empty string values are output as the attribute name only (in HTML mode).
      Returns:
        preserve the preserve flag

    - #### setPreserveEmptyAttributes

          public void setPreserveEmptyAttributes(boolean preserve)

      Deprecated.
      Sets the preserveEmptyAttribute flag. If flag is false, then' attributes with empty string values are output as the attribute name only (in HTML mode).
      Parameters:
        `preserve` - the preserve flag

    - #### getLastPrintable

          public char getLastPrintable()

      Deprecated.
      Returns the last printable character based on the selected encoding. Control characters and non-printable characters are always printed as character references.

    - #### whichMethod

          public static java.lang.String whichMethod(org.w3c.dom.Document doc)

      Deprecated.
      Determine the output method for the specified document. If the document is an instance of `HTMLDocument` then the method is said to be `html`. If the root element is 'html' and all text nodes preceding the root element are all whitespace, then the method is said to be `html`. Otherwise the method is `xml`.
      Parameters:
        `doc` - The document to check
      Returns:
        The suitable method

    - #### whichDoctypePublic

          public static java.lang.String whichDoctypePublic(org.w3c.dom.Document doc)

      Deprecated.
      Returns the document type public identifier specified for this document, or null.

    - #### whichDoctypeSystem

          public static java.lang.String whichDoctypeSystem(org.w3c.dom.Document doc)

      Deprecated.
      Returns the document type system identifier specified for this document, or null.

    - #### whichMediaType

          public static java.lang.String whichMediaType(java.lang.String method)

      Deprecated.
      Returns the suitable media format for a document output with the specified method.

Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.