|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.ac.starlink.util.XmlWriter
public class XmlWriter
Provides methods for writing XML output to a stream.
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XmlWriter()
System.out
.
public XmlWriter(java.io.PrintStream out)
out
- destination streamMethod Detail |
---|
public 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 element
java.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 value
public static java.lang.String formatText(java.lang.String text)
text
- the input text
public java.lang.String getIndent(int level)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |