|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.jdom.output.XMLOutputter
XMLOutputter
takes a JDOM tree and formats it to a
stream as XML. The outputter can manage many styles of document
formatting, from untouched to pretty printed. The default is to
output the document content exactly as created, but this can be
changed with the various set*()
methods.
There are output(...)
methods to print any of the
standard JDOM classes, including Document
and
Element
, to either a Writer
or an
OutputStream
. Warning: When outputting to a
Writer, make sure the writer's encoding matches the encoding setting
in the XMLOutputter. This ensures the encoding in which the content
is written (controlled by the Writer configuration) matches the
encoding placed in the document's XML declaration (controlled by the
XMLOutputter). Because a Writer cannot be queried for its encoding,
the information must be passed to the XMLOutputter manually in its
constructor or via the setEncoding() method. The default XMLOutputter
encoding is UTF-8.
The methods outputString(...)
are for convenience
only; for top performance you should call one of the
output(...)
and pass in your own Writer
or
OutputStream
if possible.
XML declarations are always printed on their own line followed by a
line seperator (this doesn't change the semantics of the document). To
omit printing of the declaration use setOmitDeclaration
.
To omit printing of the encoding in the declaration use
setOmitEncoding
. Unfortunatly there is currently no way
to know the original encoding of the document.
Empty elements are by default printed as <empty/>, but this can
be configured with setExpandEmptyElements
to cause them to
be expanded to <empty></empty>.
Several modes are available to effect the way textual content is printed. All modes are configurable through corresponding set*() methods. Below is a table which explains the modes and the effect on the resulting output.
Text Mode | Resulting behavior. |
---|---|
Default | All content is printed in the format it was created, no whitespace or line separators are are added or removed. |
TrimAllWhite | Content between tags consisting of all whitespace is not printed. If the content contains even one non-whitespace character, it is printed verbatim, whitespace and all. |
TextTrim | Same as TrimAllWhite, plus leading/trailing whitespace are trimmed. |
TextNormalize | Same as TextTrim, in addition interior whitespace is compressed to a single space. |
For pretty-print output, use setNewlines
in conjunction
with setIndent
. Setting newlines to true
causes
tags to be aligned and possibly indented. With newlines true
,
whitespace might be added back to fit alignment needs. In most cases
texual content is aligned with the surrounding tags (after the
appropriate text mode is applied). In the case where the only content
between the start and end tags is textual, the start tag, text, and end
tag are all printed on the same line.
When a element has a xml:space attribute with the value of "preserve", all formating is turned off and reverts back to the default until the element and it's contents have been printed. If a nested element contains another xml:space with the value "default" formatting is turned back on for the child element and then off for the remainder of the parent element.
Inner Class Summary | |
protected class |
XMLOutputter.NamespaceStack
Our own null subclass of NamespaceStack. |
Constructor Summary | |
XMLOutputter()
This will create an XMLOutputter with no additional
whitespace (indent or newlines) added; the whitespace from the
element text content is fully preserved. |
|
XMLOutputter(java.lang.String indent)
This will create an XMLOutputter with the given indent
added but no new lines added; all whitespace from the element text
content is included as well. |
|
XMLOutputter(java.lang.String indent,
boolean newlines)
This will create an XMLOutputter with the given indent
that prints newlines only if newlines is
true ; all whitespace from the element text content is
included as well. |
|
XMLOutputter(java.lang.String indent,
boolean newlines,
java.lang.String encoding)
This will create an XMLOutputter with
the given indent and new lines printing only if
newlines is true , and encoding format
encoding . |
|
XMLOutputter(XMLOutputter that)
This will create an XMLOutputter with all the
options as set in the given XMLOutputter . |
Method Summary | |
java.lang.Object |
clone()
Returns a copy of this XMLOutputter. |
protected XMLOutputter.NamespaceStack |
createNamespaceStack()
Factory for making new NamespaceStack objects. |
java.lang.String |
escapeAttributeEntities(java.lang.String str)
This will take the pre-defined entities in XML 1.0 and convert their character representation to the appropriate entity reference, suitable for XML attributes. |
java.lang.String |
escapeElementEntities(java.lang.String str)
This will take the three pre-defined entities in XML 1.0 (used specifically in XML elements) and convert their character representation to the appropriate entity reference, suitable for XML element content. |
protected void |
indent(java.io.Writer out,
int level)
This will print indents (only if the newlines flag was set to true , and indent is non-null). |
protected java.io.Writer |
makeWriter(java.io.OutputStream out)
Get an OutputStreamWriter, using prefered encoding (see setEncoding(java.lang.String) ). |
protected java.io.Writer |
makeWriter(java.io.OutputStream out,
java.lang.String enc)
Get an OutputStreamWriter, use specified encoding. |
protected void |
newline(java.io.Writer out)
This will print a new line only if the newlines flag was set to true. |
void |
output(CDATA cdata,
java.io.OutputStream out)
Print out a node. |
void |
output(CDATA cdata,
java.io.Writer out)
Print out a node. |
void |
output(Comment comment,
java.io.OutputStream out)
Print out a . |
void |
output(Comment comment,
java.io.Writer out)
Print out a . |
void |
output(DocType doctype,
java.io.OutputStream out)
Print out the . |
void |
output(DocType doctype,
java.io.Writer out)
Print out the . |
void |
output(Document doc,
java.io.OutputStream out)
This will print the Document to the given output stream. |
void |
output(Document doc,
java.io.Writer out)
This will print the Document to the given Writer. |
void |
output(Element element,
java.io.OutputStream out)
Print out an , including
it's s, and all
contained (child) elements, etc. |
void |
output(Element element,
java.io.Writer out)
Print out an , including
it's s, and all
contained (child) elements, etc. |
void |
output(EntityRef entity,
java.io.OutputStream out)
Print out a . |
void |
output(EntityRef entity,
java.io.Writer out)
Print out a . |
void |
output(java.util.List list,
java.io.OutputStream out)
This will handle printing out a list of nodes. |
void |
output(java.util.List list,
java.io.Writer out)
This will handle printing out a list of nodes. |
void |
output(ProcessingInstruction pi,
java.io.OutputStream out)
Print out a . |
void |
output(ProcessingInstruction pi,
java.io.Writer out)
Print out a . |
void |
output(java.lang.String string,
java.io.OutputStream out)
Deprecated. Deprecated in beta8, see output(Text,OutputStream) |
void |
output(java.lang.String string,
java.io.Writer out)
Deprecated. Deprecated in beta8, see output(Text,Writer) |
void |
output(Text text,
java.io.OutputStream out)
Print out a node. |
void |
output(Text text,
java.io.Writer out)
Print out a node. |
void |
outputElementContent(Element element,
java.io.OutputStream out)
This will handle printing out an 's content only, not including its tag, and
attributes. |
void |
outputElementContent(Element element,
java.io.Writer out)
This will handle printing out an 's content only, not including its tag, and
attributes. |
java.lang.String |
outputString(CDATA cdata)
Return a string representing a CDATA node. |
java.lang.String |
outputString(Comment comment)
Return a string representing a comment. |
java.lang.String |
outputString(DocType doctype)
Return a string representing a DocType. |
java.lang.String |
outputString(Document doc)
Return a string representing a document. |
java.lang.String |
outputString(Element element)
Return a string representing an element. |
java.lang.String |
outputString(EntityRef entity)
Return a string representing an entity. |
java.lang.String |
outputString(java.util.List list)
Return a string representing a list of nodes. |
java.lang.String |
outputString(ProcessingInstruction pi)
Return a string representing a PI. |
java.lang.String |
outputString(java.lang.String str)
Return a string representing (with trimming, normalizatio, and escaping possibly applied) a String . |
java.lang.String |
outputString(Text text)
Return a string representing a Text node. |
int |
parseArgs(java.lang.String[] args,
int i)
Parse command-line arguments of the form -omitEncoding
-indentSize 3 ...
|
protected void |
printAttributes(java.util.List attributes,
Element parent,
java.io.Writer out,
XMLOutputter.NamespaceStack namespaces)
This will handle printing of a list. |
protected void |
printCDATA(CDATA cdata,
java.io.Writer out)
This will handle printing of text. |
protected void |
printComment(Comment comment,
java.io.Writer out)
This will handle printing of comments. |
protected void |
printContentRange(java.util.List content,
int start,
int end,
java.io.Writer out,
int level,
XMLOutputter.NamespaceStack namespaces)
This will handle printing of content within a given range. |
protected void |
printDeclaration(Document doc,
java.io.Writer out,
java.lang.String encoding)
This will handle printing of the declaration. |
protected void |
printDocType(DocType docType,
java.io.Writer out)
This handle printing the DOCTYPE declaration if one exists. |
protected void |
printElement(Element element,
java.io.Writer out,
int level,
XMLOutputter.NamespaceStack namespaces)
This will handle printing of a ,
it's s, and all contained (child)
elements, etc. |
protected void |
printEntityRef(EntityRef entity,
java.io.Writer out)
This will handle printing a . |
protected void |
printProcessingInstruction(ProcessingInstruction pi,
java.io.Writer out)
This will handle printing of processing instructions. |
protected void |
printString(java.lang.String str,
java.io.Writer out)
This will handle printing a string. |
protected void |
printText(Text text,
java.io.Writer out)
This will handle printing of strings. |
protected void |
printTextRange(java.util.List content,
int start,
int end,
java.io.Writer out)
This will handle printing of a sequence of
or nodes. |
void |
setEncoding(java.lang.String encoding)
Sets the output encoding. |
void |
setExpandEmptyElements(boolean expandEmptyElements)
This will set whether empty elements are expanded from <tagName/> to
<tagName></tagName> . |
void |
setIndent(boolean doIndent)
Deprecated. Deprecated in beta9, use setIndent(String) instead |
void |
setIndent(int size)
Deprecated. Deprecated in beta9, use setIndent(String) instead |
void |
setIndent(java.lang.String indent)
This will set the indent String to use; this
is usually a String of empty spaces. |
void |
setIndentSize(int indentSize)
Deprecated. Deprecated in beta9, use setIndent(String) instead |
void |
setLineSeparator(java.lang.String separator)
This will set the newline separator ( lineSeparator ). |
void |
setNewlines(boolean newlines)
Sets whether newlines ( lineSeparator ) should
be printed. |
void |
setOmitDeclaration(boolean omitDeclaration)
This will set whether the XML declaration ( <?xml version="1.0"?> )
will be omitted or not. |
void |
setOmitEncoding(boolean omitEncoding)
This will set whether the XML declaration ( <?xml version="1.0" encoding="UTF-8"?> )
includes the encoding of the document. |
void |
setTextNormalize(boolean textNormalize)
This will set whether the text is output verbatim (false) or with whitespace normalized as per . |
void |
setTextTrim(boolean textTrim)
This will set whether the text has leading/trailing whitespace trimmed. |
void |
setTrimAllWhite(boolean trimAllWhite)
This will set whether content between tags consisting of all whitespace is printed or trimmed. |
java.lang.String |
toString()
Return a string listing of the settings for this XMLOutputter instance. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public XMLOutputter()
This will create an XMLOutputter
with no additional
whitespace (indent or newlines) added; the whitespace from the
element text content is fully preserved.
public XMLOutputter(java.lang.String indent)
This will create an XMLOutputter
with the given indent
added but no new lines added; all whitespace from the element text
content is included as well.
indent
- the indent string, usually some number of spacespublic XMLOutputter(java.lang.String indent, boolean newlines)
This will create an XMLOutputter
with the given indent
that prints newlines only if newlines
is
true
; all whitespace from the element text content is
included as well.
indent
- the indent String
, usually some number
of spacesnewlines
- true
indicates new lines should be
printed, else new lines are ignored (compacted).public XMLOutputter(java.lang.String indent, boolean newlines, java.lang.String encoding)
This will create an XMLOutputter
with
the given indent and new lines printing only if
newlines
is true
, and encoding format
encoding
.
indent
- the indent String
, usually some number
of spacesnewlines
- true
indicates new lines should be
printed, else new lines are ignored (compacted).encoding
- set encoding format. Use XML-style names like
"UTF-8" or "ISO-8859-1" or "US-ASCII"public XMLOutputter(XMLOutputter that)
This will create an XMLOutputter
with all the
options as set in the given XMLOutputter
. Note
that XMLOutputter two = (XMLOutputter)one.clone();
would work equally well.
that
- the XMLOutputter to cloneMethod Detail |
public void setLineSeparator(java.lang.String separator)
This will set the newline separator (lineSeparator
).
The default is \r\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"))
To output "UNIX-style" documents, call
setLineSeparator("\n")
. To output "Mac-style"
documents, call setLineSeparator("\r")
. DOS-style
documents use CR-LF ("\r\n"), which is the default.
Note that this only applies to newlines generated by the
outputter. If you parse an XML document that contains newlines
embedded inside a text node, and you do not call
setTextNormalize
, then the newlines will be output
verbatim, as "\n" which is how parsers normalize them.
separator
- String
line separator to use.setNewlines(boolean)
,
setTextNormalize(boolean)
public void setNewlines(boolean newlines)
Sets whether newlines (lineSeparator
) should
be printed.
newlines
- true
indicates new lines should be
printed, else new lines are ignored (compacted).setLineSeparator(String)
public void setEncoding(java.lang.String encoding)
Sets the output encoding. The name should be an accepted XML encoding.
encoding
- the encoding format. Use XML-style names like
"UTF-8" or "ISO-8859-1" or "US-ASCII"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 omit
this in uses such as WML and other wireless device protocols.
omitEncoding
- boolean
indicating whether or not
the XML declaration should indicate the document encoding.public void setOmitDeclaration(boolean omitDeclaration)
This will set whether the XML declaration
(<?xml version="1.0"?>
)
will be omitted or not. It is common to omit this in uses such
as SOAP and XML-RPC calls.
omitDeclaration
- boolean
indicating whether or not
the XML declaration should be omitted.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 setTrimAllWhite(boolean trimAllWhite)
This will set whether content between tags consisting of all whitespace is printed or trimmed.
Default: false
trimAllWhite
- boolean
true=>content consisting of
only whitespace is not print, false=>use text verbatimpublic void setTextTrim(boolean textTrim)
This will set whether the text has leading/trailing whitespace trimmed.
Default: false
textTrim
- boolean
true=>trim the leading/trailing
whitespace, false=>use text verbatimpublic void setTextNormalize(boolean textNormalize)
This will set whether the text is output verbatim (false)
or with whitespace normalized as per
.
Element.getTextNormalize()
Default: false
textNormalize
- boolean
true=>normalize the
whitespace, false=>use text verbatimpublic void setIndent(java.lang.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. Default: none (null)
indent
- String
to use for indentation.public void output(Document doc, java.io.OutputStream out) throws java.io.IOException
This will print the Document
to the given output stream.
The characters are printed using the encoding specified in the
constructor, or a default of UTF-8.
doc
- Document
to format.out
- OutputStream
to use.java.io.IOException
- - if there's any problem writing.public void output(DocType doctype, java.io.OutputStream out) throws java.io.IOException
Print out the
.
DocType
doctype
- DocType
to output.out
- OutputStream
to use.public void output(Element element, java.io.OutputStream out) throws java.io.IOException
Print out an
, including
it's Element
s, and all
contained (child) elements, etc.
Attribute
element
- Element
to output.out
- Writer
to use.public void outputElementContent(Element element, java.io.OutputStream out) throws java.io.IOException
Element
's content only, not including its tag, and
attributes. This can be useful for printing the content of an
element that contains HTML, like "<description>JDOM is
<b>fun>!</description>".
element
- Element
to output.out
- OutputStream
to use.public void output(java.util.List list, java.io.OutputStream out) throws java.io.IOException
This will handle printing out a list of nodes. This can be useful for printing the content of an element that contains HTML, like "<description>JDOM is <b>fun>!</description>".
list
- List
of nodes.out
- OutputStream
to use.public void output(CDATA cdata, java.io.OutputStream out) throws java.io.IOException
Print out a
node.
CDATA
cdata
- CDATA
to output.out
- OutputStream
to use.public void output(Text text, java.io.OutputStream out) throws java.io.IOException
Print out a
node. Perfoms
the necessary entity escaping and whitespace stripping.
Text
text
- Text
to output.out
- OutputStream
to use.public void output(Comment comment, java.io.OutputStream out) throws java.io.IOException
Print out a
.
Comment
comment
- Comment
to output.out
- OutputStream
to use.public void output(ProcessingInstruction pi, java.io.OutputStream out) throws java.io.IOException
Print out a
.
ProcessingInstruction
processingInstruction
- ProcessingInstruction
to output.out
- OutputStream
to use.public void output(EntityRef entity, java.io.OutputStream out) throws java.io.IOException
Print out a
.
EntityRef
entity
- EntityRef
to output.out
- OutputStream
to use.protected java.io.Writer makeWriter(java.io.OutputStream out) throws java.io.UnsupportedEncodingException
Get an OutputStreamWriter, using prefered encoding
(see setEncoding(java.lang.String)
).
protected java.io.Writer makeWriter(java.io.OutputStream out, java.lang.String enc) throws java.io.UnsupportedEncodingException
Get an OutputStreamWriter, use specified encoding.
public void output(Document doc, java.io.Writer out) throws java.io.IOException
This will print the Document
to the given Writer.
Warning: using your own Writer may cause the outputter's preferred character encoding to be ignored. If you use encodings other than UTF-8, we recommend using the method that takes an OutputStream instead.
doc
- Document
to format.out
- Writer
to use.java.io.IOException
- - if there's any problem writing.public void output(DocType doctype, java.io.Writer out) throws java.io.IOException
Print out the
.
DocType
doctype
- DocType
to output.out
- Writer
to use.public void output(Element element, java.io.Writer out) throws java.io.IOException
Print out an
, including
it's Element
s, and all
contained (child) elements, etc.
Attribute
element
- Element
to output.out
- Writer
to use.public void outputElementContent(Element element, java.io.Writer out) throws java.io.IOException
This will handle printing out an
's content only, not including its tag, and
attributes. This can be useful for printing the content of an
element that contains HTML, like "<description>JDOM is
<b>fun>!</description>".
Element
element
- Element
to output.out
- Writer
to use.public void output(java.util.List list, java.io.Writer out) throws java.io.IOException
This will handle printing out a list of nodes. This can be useful for printing the content of an element that contains HTML, like "<description>JDOM is <b>fun>!</description>".
list
- List
of nodes.out
- Writer
to use.public void output(CDATA cdata, java.io.Writer out) throws java.io.IOException
Print out a
node.
CDATA
cdata
- CDATA
to output.out
- Writer
to use.public void output(Text text, java.io.Writer out) throws java.io.IOException
Print out a
node. Perfoms
the necessary entity escaping and whitespace stripping.
Text
text
- Text
to output.out
- Writer
to use.public void output(Comment comment, java.io.Writer out) throws java.io.IOException
Print out a
.
Comment
comment
- Comment
to output.out
- Writer
to use.public void output(ProcessingInstruction pi, java.io.Writer out) throws java.io.IOException
Print out a
.
ProcessingInstruction
element
- ProcessingInstruction
to output.out
- Writer
to use.public void output(EntityRef entity, java.io.Writer out) throws java.io.IOException
Print out a
.
EntityRef
entity
- EntityRef
to output.out
- Writer
to use.public java.lang.String outputString(Document doc)
Return a string representing a document. Uses an internal StringWriter. Warning: a String is Unicode, which may not match the outputter's specified encoding.
doc
- Document
to format.public java.lang.String outputString(DocType doctype)
Return a string representing a DocType. Warning: a String is Unicode, which may not match the outputter's specified encoding.
doctype
- DocType
to format.public java.lang.String outputString(Element element)
Return a string representing an element. Warning: a String is Unicode, which may not match the outputter's specified encoding.
element
- Element
to format.public java.lang.String outputString(java.util.List list)
Return a string representing a list of nodes. The list is assumed to contain legal JDOM nodes.
list
- List
to format.public java.lang.String outputString(CDATA cdata)
Return a string representing a CDATA node. Warning: a String is Unicode, which may not match the outputter's specified encoding.
cdata
- CDATA
to format.public java.lang.String outputString(Text text)
Return a string representing a Text node. Warning: a String is Unicode, which may not match the outputter's specified encoding.
text
- Text
to format.public java.lang.String outputString(java.lang.String str)
Return a string representing (with trimming, normalizatio, and
escaping possibly applied) a String
. Warning: a
String is Unicode, which may not match the outputter's specified
encoding.
str
- String
to format.public java.lang.String outputString(Comment comment)
Return a string representing a comment. Warning: a String is Unicode, which may not match the outputter's specified encoding.
comment
- Comment
to format.public java.lang.String outputString(ProcessingInstruction pi)
Return a string representing a PI. Warning: a String is Unicode, which may not match the outputter's specified encoding.
pi
- ProcessingInstruction
to format.public java.lang.String outputString(EntityRef entity)
Return a string representing an entity. Warning: a String is Unicode, which may not match the outputter's specified encoding.
entity
- EntityRef
to format.protected void printDeclaration(Document doc, java.io.Writer out, java.lang.String encoding) throws java.io.IOException
This will handle printing of the declaration. Assumes XML version 1.0 since we don't directly know.
doc
- Document
whose declaration to write.out
- Writer
to use.encoding
- The encoding to add to the declarationprotected void printDocType(DocType docType, java.io.Writer out) throws java.io.IOException
This handle printing the DOCTYPE declaration if one exists.
doc
- Document
whose declaration to write.out
- Writer
to use.protected void printComment(Comment comment, java.io.Writer out) throws java.io.IOException
This will handle printing of comments.
comment
- Comment
to write.out
- Writer
to use.protected void printProcessingInstruction(ProcessingInstruction pi, java.io.Writer out) throws java.io.IOException
This will handle printing of processing instructions.
comment
- ProcessingInstruction
to write.out
- Writer
to use.protected void printEntityRef(EntityRef entity, java.io.Writer out) throws java.io.IOException
This will handle printing a
.
Only the entity reference such as EntityRef
&entity;
will be printed. However, subclasses are free to override
this method to print the contents of the entity instead.
entity
- EntityRef
to output.out
- Writer
to use.protected void printCDATA(CDATA cdata, java.io.Writer out) throws java.io.IOException
This will handle printing of
text.
CDATA
cdata
- CDATA
to output.out
- Writer
to use.protected void printText(Text text, java.io.Writer out) throws java.io.IOException
This will handle printing of
strings.
Text
text
- Text
to write.out
- Writer
to use.protected void printString(java.lang.String str, java.io.Writer out) throws java.io.IOException
protected void printElement(Element element, java.io.Writer out, int level, XMLOutputter.NamespaceStack namespaces) throws java.io.IOException
This will handle printing of a
,
it's Element
s, and all contained (child)
elements, etc.
Attribute
element
- Element
to output.out
- Writer
to use.indent
- int
level of indention.namespaces
- List
stack of Namespaces in scope.protected void printContentRange(java.util.List content, int start, int end, java.io.Writer out, int level, XMLOutputter.NamespaceStack namespaces) throws java.io.IOException
This will handle printing of content within a given range. The range to print is specified in typical Java fashion; the starting index is inclusive, while the ending index is exclusive.
content
- List
of content to outputstarting
- index of first content node (inclusive.ending
- index of last content node (exclusive).out
- Writer
to use.level
- int
level of indentation.namespaces
- List
stack of Namespaces in scope.protected void printTextRange(java.util.List content, int start, int end, java.io.Writer out) throws java.io.IOException
This will handle printing of a sequence of
or CDATA
nodes. It is a error to have any other
pass this method any other type of node.
Text
content
- List
of content to outputstarting
- index of first content node (inclusive).ending
- index of last content node (exclusive).out
- Writer
to use.protected void printAttributes(java.util.List attributes, Element parent, java.io.Writer out, XMLOutputter.NamespaceStack namespaces) throws java.io.IOException
This will handle printing of a
list.
Attribute
attributes
- List
of Attribute objctsout
- Writer
to useprotected void newline(java.io.Writer out) throws java.io.IOException
This will print a new line only if the newlines flag was set to true.
out
- Writer
to useprotected void indent(java.io.Writer out, int level) throws java.io.IOException
This will print indents (only if the newlines flag was
set to true
, and indent is non-null).
out
- Writer
to uselevel
- current indent level (number of tabs)public java.lang.String escapeAttributeEntities(java.lang.String str)
This will take the pre-defined entities in XML 1.0 and convert their character representation to the appropriate entity reference, suitable for XML attributes. It does no converstion for ' because it's not necessary as the outputter writes attributes surrounded by double-quotes.
str
- String
input to escape.String
with escaped content.public java.lang.String escapeElementEntities(java.lang.String str)
This will take the three pre-defined entities in XML 1.0 (used specifically in XML elements) and convert their character representation to the appropriate entity reference, suitable for XML element content.
st
- String
input to escape.String
with escaped content.public int parseArgs(java.lang.String[] args, int i)
Parse command-line arguments of the form -omitEncoding
-indentSize 3 ...
public java.lang.Object clone()
clone
in class java.lang.Object
public java.lang.String toString()
Return a string listing of the settings for this XMLOutputter instance.
toString
in class java.lang.Object
protected XMLOutputter.NamespaceStack createNamespaceStack()
Factory for making new NamespaceStack objects. The NamespaceStack created is actually an inner class extending the package protected NamespaceStack, as a way to make NamespaceStack "friendly" toward subclassers.
public void output(java.lang.String string, java.io.OutputStream out) throws java.io.IOException
output(Text,OutputStream)
Print out a
. Perfoms
the necessary entity escaping and whitespace stripping. String
string
- String
to output.out
- OutputStream
to use.public void output(java.lang.String string, java.io.Writer out) throws java.io.IOException
output(Text,Writer)
Print out a
. Perfoms
the necessary entity escaping and whitespace stripping.
String
string
- String
to output.out
- Writer
to use.public void setIndent(boolean doIndent)
Set the indent on or off, newlines must be set to true
for indentation to actually occur. If setting on, will use the
value of STANDARD_INDENT, which is usually two spaces.
doIndent
- if true, set indenting on; if false, set indenting offpublic void setIndent(int size)
This will set the indent String
's size; a size
of 4 would result in the indentation being equivalent to the
String
" " (four spaces).
size
- int
number of spaces in indentation.public void setIndentSize(int indentSize)
This will set the indent String
's size; an indentSize
of 4 would result in the indentation being equivalent to the
String
" " (four spaces).
indentSize
- int
number of spaces in indentation.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |