|
|||||||||
| 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(PrintStream out)
Constructs a new writer which writes to a given print stream. |
|
| Method Summary | |
|---|---|
void |
addElement(String elName,
String attList,
String content)
Writes a whole element with given attribute list and content. |
void |
endElement(String elName)
Outputs an end element tag. |
static String |
formatAttribute(String name,
String value)
Turns a name,value pair into an attribute assignment suitable for putting in an XML start tag. |
static String |
formatText(String text)
Performs necessary special character escaping for text which will be written as XML CDATA. |
String |
getIndent(int level)
Returns the indentation string associated with a given level. |
int |
getLevel()
Returns the current element nesting level. |
void |
print(String txt)
Outputs a literal string in the output. |
void |
println(String txt)
Outputs a literal string in the output followed by a newline character. |
void |
setOut(PrintStream out)
Sets the destination stream for this writer. |
void |
startElement(String elName)
Outputs a start element tag with no attributes. |
void |
startElement(String elName,
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(PrintStream out)
out - destination stream| Method Detail |
|---|
public void writeDeclaration()
public void startElement(String elName)
elName - name of the element
public void startElement(String elName,
String attList)
elName - name of the elementattList - literal string giving the attribute listpublic void endElement(String elName)
elName - name of the element
IllegalArgumentException - if that element's not ready to finish
public void addElement(String elName,
String attList,
String content)
elName - name of the elementattList - literal string giving the attribute listcontent - literal string giving the element contentpublic void print(String txt)
txt - literal textpublic void setOut(PrintStream out)
out - new destination streampublic void println(String txt)
txt - literal textpublic int getLevel()
public static String formatAttribute(String name,
String value)
name - the attribute namevalue - the attribute value
public static String formatText(String text)
text - the input text
public String getIndent(int level)
|
Copyright © 2004 CLRC: Central Laboratory of the Research Councils. All rights reserved. | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||