public class XmlWriter
extends java.lang.Object
Constructor | Description |
---|---|
XmlWriter() |
Constructs a new writer which outputs to
System.out . |
XmlWriter(java.io.PrintStream out) |
Constructs a new writer which writes to a given print stream.
|
Modifier and Type | Method | Description |
---|---|---|
void |
addElement(java.lang.String elName,
java.lang.String attList,
java.lang.String content) |
Writes a whole element with given attribute list and content.
|
void |
endElement(java.lang.String elName) |
Outputs an end element tag.
|
static java.lang.String |
formatAttribute(java.lang.String name,
java.lang.String value) |
Turns a name,value pair into an attribute assignment suitable for
putting in an XML start tag.
|
static java.lang.String |
formatText(java.lang.String text) |
Performs necessary special character escaping for text which
will be written as XML CDATA.
|
java.lang.String |
getIndent(int level) |
Returns the indentation string associated with a given level.
|
int |
getLevel() |
Returns the current element nesting level.
|
void |
print(java.lang.String txt) |
Outputs a literal string in the output.
|
void |
println(java.lang.String txt) |
Outputs a literal string in the output followed by a newline character.
|
void |
setOut(java.io.PrintStream out) |
Sets the destination stream for this writer.
|
void |
startElement(java.lang.String elName) |
Outputs a start element tag with no attributes.
|
void |
startElement(java.lang.String elName,
java.lang.String attList) |
Outputs a start element tag with a given list of attributes.
|
void |
writeDeclaration() |
Writes an XML declaration.
|
public XmlWriter()
System.out
.public XmlWriter(java.io.PrintStream out)
out
- destination streampublic void writeDeclaration()
public void startElement(java.lang.String elName)
elName
- name of the elementpublic void startElement(java.lang.String elName, java.lang.String attList)
elName
- name of the elementattList
- literal string giving the attribute listpublic void endElement(java.lang.String elName)
elName
- name of the elementjava.lang.IllegalArgumentException
- if that element's not ready to finishpublic void addElement(java.lang.String elName, java.lang.String attList, java.lang.String content)
elName
- name of the elementattList
- literal string giving the attribute listcontent
- literal string giving the element contentpublic void print(java.lang.String txt)
txt
- literal textpublic void setOut(java.io.PrintStream out)
out
- new destination streampublic void println(java.lang.String txt)
txt
- literal textpublic int getLevel()
public static java.lang.String formatAttribute(java.lang.String name, java.lang.String value)
name
- the attribute namevalue
- the attribute valuepublic static java.lang.String formatText(java.lang.String text)
text
- the input textpublic java.lang.String getIndent(int level)
Copyright © 2018 Central Laboratory of the Research Councils. All Rights Reserved.