| Constructor and Description |
|---|
OutputFormat()
Creates an
OutputFormat with no additional whitespace
(indent or new lines) added. |
OutputFormat(String indent)
Creates an
OutputFormat with the given indent added but no
new lines added. |
OutputFormat(String indent,
boolean newlines)
Creates an
OutputFormat with the given indent added with
optional newlines between the Elements. |
OutputFormat(String indent,
boolean newlines,
String encoding)
Creates an
OutputFormat with the given indent added with
optional newlines between the Elements and the given encoding format. |
| Modifier and Type | Method and Description |
|---|---|
static OutputFormat |
createCompactFormat()
A static helper method to create the default compact format.
|
static OutputFormat |
createPrettyPrint()
A static helper method to create the default pretty printing format.
|
char |
getAttributeQuoteCharacter() |
String |
getEncoding() |
String |
getIndent() |
String |
getLineSeparator() |
int |
getNewLineAfterNTags() |
boolean |
isEscapeText()
DOCUMENT ME!
|
boolean |
isExpandEmptyElements() |
boolean |
isNewLineAfterDeclaration()
DOCUMENT ME!
|
boolean |
isNewlines() |
boolean |
isOmitEncoding() |
boolean |
isSuppressDeclaration()
DOCUMENT ME!
|
boolean |
isTrimText() |
boolean |
isXHTML()
Whether or not to use the XHTML standard: like HTML but passes an XML
parser with real, closed tags.
|
void |
setAttributeQuoteCharacter(char quoteChar)
Sets the character used to quote attribute values.
|
void |
setEncoding(String encoding)
DOCUMENT ME!
|
void |
setEscapeText(boolean escapeText)
Sets whether text output should be escaped or not.
|
void |
setExpandEmptyElements(boolean expandEmptyElements)
This will set whether empty elements are expanded from
<tagName> to
<tagName></tagName>. |
void |
setIndent(boolean doIndent)
Set the indent on or off.
|
void |
setIndent(String indent)
This will set the indent
String to use; this is usually a
String of empty spaces. |
void |
setIndentSize(int indentSize)
This will set the indent
String's size; an indentSize of 4
would result in the indention being equivalent to the String
" " (four space characters). |
void |
setLineSeparator(String separator)
This will set the new-line separator.
|
void |
setNewLineAfterDeclaration(boolean newLineAfterDeclaration)
This will set whether a new line is printed after the XML declaration
(assuming it is not supressed.)
|
void |
setNewLineAfterNTags(int tagCount)
Controls output of a line.separator every tagCount tags when isNewlines
is false.
|
void |
setNewlines(boolean newlines)
DOCUMENT ME!
|
void |
setOmitEncoding(boolean omitEncoding)
This will set whether the XML declaration (
<? |
void |
setSuppressDeclaration(boolean suppressDeclaration)
This will set whether the XML declaration (
<? |
void |
setTrimText(boolean trimText)
This will set whether the text is output verbatim (false) or with
whitespace stripped as per
. |
void |
setXHTML(boolean xhtml)
This will set whether or not to use the XHTML standard: like HTML but
passes an XML parser with real, closed tags.
|
public OutputFormat()
OutputFormat with no additional whitespace
(indent or new lines) added. The whitespace from the element text content
is fully preserved.public OutputFormat(String indent)
OutputFormat with the given indent added but no
new lines added. All whitespace from element text will be included.indent - is the indent string to be used for indentation (usually a
number of spaces).public OutputFormat(String indent, boolean newlines)
OutputFormat with the given indent added with
optional newlines between the Elements. All whitespace from element text
will be included.indent - is the indent string to be used for indentation (usually a
number of spaces).newlines - whether new lines are added to layout thepublic OutputFormat(String indent, boolean newlines, String encoding)
OutputFormat with the given indent added with
optional newlines between the Elements and the given encoding format.indent - is the indent string to be used for indentation (usually a
number of spaces).newlines - whether new lines are added to layout theencoding - is the text encoding to use for writing the XMLpublic static OutputFormat createCompactFormat()
public static OutputFormat createPrettyPrint()
public char getAttributeQuoteCharacter()
public String getEncoding()
public String getIndent()
public String getLineSeparator()
public int getNewLineAfterNTags()
public boolean isEscapeText()
public boolean isExpandEmptyElements()
public boolean isNewLineAfterDeclaration()
public boolean isNewlines()
public boolean isOmitEncoding()
public boolean isSuppressDeclaration()
<?xml
version="1.0"?>) should be suppressed else false.public boolean isTrimText()
public boolean isXHTML()
Whether or not to use the XHTML standard: like HTML but passes an XML parser with real, closed tags. Also, XHTML CDATA sections will be output with the CDATA delimiters: ( " <![CDATA[ " and " ]]> " ) otherwise, the class HTMLWriter will output the CDATA text, but not the delimiters.
Default is false
public void setAttributeQuoteCharacter(char quoteChar)
IllegalArgumentException will be thrown.quoteChar - The character to use when quoting attribute values.IllegalArgumentException - If the specified character is not a valid XML attribute quote
character.public void setEncoding(String encoding)
encoding - encoding formatpublic void setEscapeText(boolean escapeText)
escapeText - DOCUMENT ME!public void setExpandEmptyElements(boolean expandEmptyElements)
This will set whether empty elements are expanded from
<tagName> to
<tagName></tagName>.
expandEmptyElements - boolean indicating whether or not empty elements
should be expanded.public void setIndent(boolean doIndent)
doIndent - if true, set indenting on; if false, set indenting offpublic void setIndent(String indent)
This will set the indent String to use; this is usually a
String of empty spaces. If you pass null, or the empty
string (""), then no indentation will happen.
indent - String to use for indentation.public void setIndentSize(int indentSize)
This will set the indent String's size; an indentSize of 4
would result in the indention being equivalent to the String
" " (four space characters).
indentSize - int number of spaces in indentation.public void setLineSeparator(String separator)
This will set the new-line separator. The default is \n.
Note that if the "newlines" property is false, this value is irrelevant.
To make it output the system default line ending string, call
setLineSeparator(System.getProperty("line.separator"))
separator - String line separator to use.setNewlines(boolean)public void setNewLineAfterDeclaration(boolean newLineAfterDeclaration)
This will set whether a new line is printed after the XML declaration (assuming it is not supressed.)
newLineAfterDeclaration - boolean indicating whether or not to print new
line following the XML declaration. The default is true.public void setNewLineAfterNTags(int tagCount)
tagCount - DOCUMENT ME!public void setNewlines(boolean newlines)
newlines - true indicates new lines should be printed, else
new lines are ignored (compacted).setLineSeparator(String)public void setOmitEncoding(boolean omitEncoding)
This will set whether the XML declaration (<?xml version="1.0"
encoding="UTF-8"?>) includes the encoding of the document. It
is common to suppress this in protocols such as WML and SOAP.
omitEncoding - boolean indicating whether or not the XML
declaration should indicate the document encoding.public void setSuppressDeclaration(boolean suppressDeclaration)
This will set whether the XML declaration (<?xml version="1.0"
encoding="UTF-8"?>) is included or not. It is common to
suppress this in protocols such as WML and SOAP.
suppressDeclaration - boolean indicating whether or not the XML
declaration should be suppressed.public void setTrimText(boolean trimText)
This will set whether the text is output verbatim (false) or with
whitespace stripped as per .
org.dom4j.Element#getTextTrim()
Default: false
trimText - boolean true=>trim the whitespace, false=>use
text verbatimpublic void setXHTML(boolean xhtml)
This will set whether or not to use the XHTML standard: like HTML but passes an XML parser with real, closed tags. Also, XHTML CDATA sections will be output with the CDATA delimiters: ( " <[CDATA[ " and " ]]< ) otherwise, the class HTMLWriter will output the CDATA text, but not the delimiters.
Default: false
xhtml - boolean true=>conform to XHTML, false=>conform to
HTML, can have unclosed tags, etc.Copyright © 2013 intarsys consulting GmbH. All Rights Reserved.