public class OutputFormat
extends java.lang.Object
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
Serializer
,
Method
,
LineSeparator
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 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.
|
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.
|
public OutputFormat()
public OutputFormat(java.lang.String method, java.lang.String encoding, boolean indenting)
method
- The specified output methodencoding
- The specified encodingindenting
- True for pretty printingsetEncoding(java.lang.String)
,
setIndenting(boolean)
,
setMethod(java.lang.String)
public OutputFormat(org.w3c.dom.Document doc)
doc
- The document to outputwhichMethod(org.w3c.dom.Document)
public OutputFormat(org.w3c.dom.Document doc, java.lang.String encoding, boolean indenting)
doc
- The document to outputencoding
- The specified encodingindenting
- True for pretty printingsetEncoding(java.lang.String)
,
setIndenting(boolean)
,
whichMethod(org.w3c.dom.Document)
public java.lang.String getMethod()
whichMethod(org.w3c.dom.Document)
.public void setMethod(java.lang.String method)
method
- The output method, or nullgetMethod()
public java.lang.String getVersion()
public void setVersion(java.lang.String version)
version
- The output method version, or nullgetVersion()
public int getIndent()
setIndenting(boolean)
public boolean getIndenting()
public void setIndent(int indent)
setIndenting(boolean)
will reset this
value to zero (off) or the default (on).indent
- The indentation, or zeropublic void setIndenting(boolean on)
OutputFormat.Defaults.Indent
and OutputFormat.Defaults.LineWidth
).
To specify a different indentation level or line wrapping,
use setIndent(int)
and setLineWidth(int)
.on
- True if indentation should be onpublic java.lang.String getEncoding()
public void setEncoding(java.lang.String encoding)
Writer
.encoding
- The encoding, or nullgetEncoding()
public void setEncoding(EncodingInfo encInfo)
EncodingInfo
instance.public EncodingInfo getEncodingInfo() throws java.io.UnsupportedEncodingException
EncodingInfo
instance for the encoding.java.io.UnsupportedEncodingException
setEncoding(java.lang.String)
public void setAllowJavaNames(boolean allow)
public boolean setAllowJavaNames()
public java.lang.String getMediaType()
whichMediaType(java.lang.String)
.public void setMediaType(java.lang.String mediaType)
mediaType
- The specified media typegetMediaType()
public void setDoctype(java.lang.String publicId, java.lang.String systemId)
publicId
- The public identifier, or nullsystemId
- The system identifier, or nullpublic java.lang.String getDoctypePublic()
public java.lang.String getDoctypeSystem()
public boolean getOmitComments()
public void setOmitComments(boolean omit)
omit
- True if comments should be ommitedpublic boolean getOmitDocumentType()
public void setOmitDocumentType(boolean omit)
omit
- True if DOCTYPE declaration should be ommitedpublic boolean getOmitXMLDeclaration()
public void setOmitXMLDeclaration(boolean omit)
omit
- True if XML declaration should be ommitedpublic boolean getStandalone()
public void setStandalone(boolean standalone)
standalone
- True if document DTD is standalonepublic java.lang.String[] getCDataElements()
public boolean isCDataElement(java.lang.String tagName)
tagName
- The element's tag namepublic void setCDataElements(java.lang.String[] cdataElements)
cdataElements
- List of CDATA element tag namespublic java.lang.String[] getNonEscapingElements()
public boolean isNonEscapingElement(java.lang.String tagName)
tagName
- The element's tag namepublic void setNonEscapingElements(java.lang.String[] nonEscapingElements)
nonEscapingElements
- List of unescaped element tag namespublic java.lang.String getLineSeparator()
public void setLineSeparator(java.lang.String lineSeparator)
lineSeparator
- The specified line separatorpublic boolean getPreserveSpace()
public void setPreserveSpace(boolean preserve)
preserve
- True if spaces should be preservedpublic int getLineWidth()
public void setLineWidth(int lineWidth)
setIndenting(boolean)
will reset this
value to zero (off) or the default (on).lineWidth
- The line width to use, zero for defaultgetLineWidth()
,
setIndenting(boolean)
public boolean getPreserveEmptyAttributes()
public void setPreserveEmptyAttributes(boolean preserve)
preserve
- the preserve flagpublic char getLastPrintable()
public static java.lang.String whichMethod(org.w3c.dom.Document doc)
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.doc
- The document to checkpublic static java.lang.String whichDoctypePublic(org.w3c.dom.Document doc)
public static java.lang.String whichDoctypeSystem(org.w3c.dom.Document doc)
public static java.lang.String whichMediaType(java.lang.String method)
Copyright © 1999-2022 The Apache Software Foundation. All Rights Reserved.