public class XMLWriter extends Object
| Constructor and Description |
|---|
XMLWriter(OutputStream out,
String dtdFile)
Create an XML writer with indenting enabled by default.
|
XMLWriter(OutputStreamWriter out,
String dtdFile)
Create an XML writer with indenting enabled by default.
|
XMLWriter(String filename,
String dtdFile)
Create a XMLWriter with the path to a file.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAttr(String name,
String value)
add an attribute to the opened tag.
|
void |
addComplexContent(String s,
boolean b)
Add a complex "text child", it will be enclosed into CDATA markers
|
void |
addContent(String s)
Add a "text child"
|
void |
addFormatedContent(String s,
boolean b)
Add a "text child", already formated: should _NOT_ be escaped
|
void |
addTag(String name)
Add (i.e.
|
void |
addTag(String tag,
String content)
Add (i.e.
|
void |
addTag(String name,
String[] attributes)
Add (i.e.
|
void |
addTag(String name,
String[] attributes,
String content)
Add (i.e.
|
void |
close()
Close the writer: automatically closes all open tags and the underlying output stream.
|
void |
closeTag()
Close the currently opened tag.
|
String |
getBuffer()
If
toBuffer has previously been called, stop saving to buffer. |
static boolean |
isValidId(String id)
Indicates if the given string is a valid GINsim ID (contains only a-z, A-Z, 0-9, "_" characters, not starting with a digit)
|
void |
openTag(String name)
Open a tag in the XML output file
|
void |
openTag(String name,
String[] attributes)
Open a tag and add it the specified attributes.
|
void |
toBuffer()
ask to store the next calls into a string buffer.
|
void |
write(char c)
Write a single character directly t the output
|
void |
write(String s)
Write a String directly (no escaping)
|
void |
writeEsc(String s,
boolean isAttVal)
Write a string, using escaping as needed.
|
public XMLWriter(String filename, String dtdFile) throws IOException
filename - the path to the output filedtdFile - path to the DTD fileIOException - if the output can not be written or failspublic XMLWriter(OutputStreamWriter out, String dtdFile) throws IOException
out - the output writerdtdFile - path to the DTD fileIOException - if the output can not be written or failspublic XMLWriter(OutputStream out, String dtdFile) throws IOException
out - the output streamdtdFile - path to the DTD fileIOException - if the output can not be written or failspublic static boolean isValidId(String id)
id - the string to testpublic void toBuffer()
throws IOException
getBuffer() to stop it and get the content of the buffer.IOException - if writing failspublic String getBuffer()
toBuffer has previously been called, stop saving to buffer.public void writeEsc(String s, boolean isAttVal) throws IOException
s - the String to writeisAttVal - specifies if this is an attribute value (uses a different escaping)IOException - if writing failspublic void write(String s) throws IOException
s - the string to writeIOException - if writing failspublic void write(char c)
throws IOException
c - the characterIOException - if writing failspublic void openTag(String name) throws IOException
name - the tag nameIOException - if writing failspublic void addTag(String name) throws IOException
name - the tag nameIOException - if writing failspublic void addTag(String name, String[] attributes, String content) throws IOException
name - the tag nameattributes - the list of attributes and their valuescontent - the content textIOException - if writing failspublic void openTag(String name, String[] attributes) throws IOException
name - the tag nameattributes - the list of attributes and their valuesIOException - if writing failspublic void addTag(String name, String[] attributes) throws IOException
name - the tag nameattributes - the list of attributes and their valuesIOException - if writing failspublic void addTag(String tag, String content) throws IOException
tag - the tag namecontent - the content to addIOException - if writing failspublic void closeTag()
throws IOException
IOException - if writing failspublic void addAttr(String name, String value) throws IOException
name - the attribute namevalue - the attribute valueIOException - if writing failspublic void addContent(String s) throws IOException
s - the content to write (will be escaped as needed)IOException - if writing failspublic void addFormatedContent(String s, boolean b) throws IOException
s - the formatted contentb - if true, then the file might get indentedIOException - if writing failspublic void addComplexContent(String s, boolean b) throws IOException
s - the complex contentb - if true, then the file might get indentedIOException - if writing failspublic void close()
throws IOException
IOException - if writing failsCopyright © 2012–2020. All rights reserved.