|
||||||||||
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. This formatter performs typical
document formatting. The XML declaration
and processing instructions are always on their own lines. Empty
elements are printed as false
for printing new lines.
Constructor Summary | |
XMLOutputter()
This will create an XMLOutputter with
a two-space indent and new lines on. |
|
XMLOutputter(java.lang.String indent)
This will create an XMLOutputter with
the given indent and new lines on. |
|
XMLOutputter(java.lang.String indent,
boolean newlines)
This will create an XMLOutputter with
the given indent and new lines printing only if newlines is
true . |
Method Summary | |
protected void |
indent(java.io.PrintWriter out,
int level)
This will print the proper indent characters for the given indent level. |
protected void |
maybePrintln(java.io.PrintWriter out)
This will print a new line only if the newlines flag was set to true |
void |
output(Document doc,
java.io.OutputStream out)
This will print the Document to the given output stream. |
protected void |
printAttributes(java.util.List attributes,
java.io.PrintWriter out)
This will handle printing out an list. |
protected void |
printDeclaration(Document doc,
java.io.PrintWriter out)
This will print the declaration to the given output stream. |
protected void |
printDocType(DocType docType,
java.io.PrintWriter out)
This will print the DOCTYPE declaration if one exists. |
protected void |
printElement(Element element,
java.io.PrintWriter out,
int indentLevel)
This will handle printing out an ,
its s, and its value. |
protected void |
printProcessingInstructions(java.util.List pis,
java.io.PrintWriter out)
This will print the processing instructions to the given output stream. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public XMLOutputter()
This will create an XMLOutputter
with
a two-space indent and new lines on.
public XMLOutputter(java.lang.String indent)
This will create an XMLOutputter
with
the given indent and new lines on.
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 and new lines printing only if newlines is
true
.
indent
- the indent String
, usually some number
of spacesnewlines
- true
indicates new lines should be
printed, else new lines are ignored (compacted).Method Detail |
protected void indent(java.io.PrintWriter out, int level)
This will print the proper indent characters for the given indent level.
out
- PrintWriter
to write tolevel
- int
indentation levelprotected void maybePrintln(java.io.PrintWriter out)
This will print a new line only if the newlines flag was set to true
out
- PrintWriter
to write topublic 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 UTF-8 encoding.
doc
- Document
to format.out
- PrintWriter
to write to.IOException
- - if there's any problem writing.protected void printDeclaration(Document doc, java.io.PrintWriter out)
This will print the declaration to the given output stream. Assumes XML version 1.0 since we don't directly know.
docType
- DocType
whose declaration to write.out
- PrintWriter
to write to.protected void printDocType(DocType docType, java.io.PrintWriter out)
This will print the DOCTYPE declaration if one exists.
doc
- Document
whose declaration to write.out
- PrintWriter
to write to.protected void printProcessingInstructions(java.util.List pis, java.io.PrintWriter out)
This will print the processing instructions to the given output stream.
Assumes the List
contains nothing but
ProcessingInstruction
objects.
pis
- List
of ProcessingInstructions to printout
- PrintWriter
to write toprotected void printElement(Element element, java.io.PrintWriter out, int indentLevel)
This will handle printing out an
,
its Element
s, and its value.
Attribute
element
- Element
to output.out
- PrintWriter
to write to.indent
- int
level of indention.protected void printAttributes(java.util.List attributes, java.io.PrintWriter out)
This will handle printing out an
list.
Attribute
attributes
- List
of Attribute objctsout
- PrintWriter
to write to
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |