public class XMLWriter extends Object implements XMLTagWriter
Modifier and Type | Field and Description |
---|---|
protected boolean |
closed |
protected String |
defaultNameSpace |
protected org.freehep.util.io.IndentPrintWriter |
writer |
Constructor and Description |
---|
XMLWriter(Writer w) |
XMLWriter(Writer w,
String indentString) |
XMLWriter(Writer w,
String indentString,
String defaultNameSpace) |
Modifier and Type | Method and Description |
---|---|
protected void |
checkNameValid(String s) |
void |
close()
closes the writer
|
void |
closeDoc()
Closes the document, and checks if you closed all the tags
|
void |
closeTag()
Closes the current XML tag and decreases the indentation level
|
static String |
normalize(String s)
Normalizes the given string for an Attribute value
|
static String |
normalizeText(String s)
Normalizes the given string for Text
|
void |
openDoc()
Opens the document with an xml header
|
void |
openDoc(String version,
String encoding,
boolean standalone)
Opens the document with an xml header
|
void |
openTag(String name)
Prints a new XML tag and increases the identation level
|
void |
openTag(String namespace,
String name)
Prints a new XML tag and increases the identation level
|
void |
print(Node node)
Prints a DOM node, recursively.
|
void |
print(String text)
Prints character data, while escaping < and >
|
protected void |
printAttributes(int tagLength) |
void |
printComment(String comment)
Print a comment
|
void |
println(String text)
Prints character data, while escaping < and >
|
void |
printTag(String name)
Prints an empty XML tag.
|
void |
printTag(String namespace,
String name)
Prints an empty XML tag.
|
void |
referToDTD(String name,
String system)
Writes a reference to a DTD
|
void |
referToDTD(String name,
String pid,
String ref)
Writes a reference to a DTD
|
void |
setAttribute(String name,
boolean value)
Set boolean attribute
|
void |
setAttribute(String name,
byte value)
Set byte attribute
|
void |
setAttribute(String name,
char value)
Set char attribute
|
void |
setAttribute(String name,
Color value)
Set Color attribute
|
void |
setAttribute(String name,
double value)
Set double attribute
|
void |
setAttribute(String name,
float value)
Set float attribute
|
void |
setAttribute(String name,
int value)
Set int attribute
|
void |
setAttribute(String name,
long value)
Set long attribute
|
void |
setAttribute(String name,
short value)
Set short attribute
|
void |
setAttribute(String name,
String value)
Sets an attribute which will be included in the next tag
printed by openTag or printTag
|
void |
setAttribute(String ns,
String name,
boolean value)
Set boolean attribute
|
void |
setAttribute(String ns,
String name,
byte value)
Set byte attribute
|
void |
setAttribute(String ns,
String name,
char value)
Set char attribute
|
void |
setAttribute(String ns,
String name,
Color value)
Set Color attribute
|
void |
setAttribute(String ns,
String name,
double value)
Set double attribute
|
void |
setAttribute(String ns,
String name,
float value)
Set float attribute
|
void |
setAttribute(String ns,
String name,
int value)
Set int attribute
|
void |
setAttribute(String ns,
String name,
long value)
Set long attribute
|
void |
setAttribute(String ns,
String name,
short value)
Set short attribute
|
void |
setAttribute(String namespace,
String name,
String value)
Set String attribute
|
protected boolean closed
protected org.freehep.util.io.IndentPrintWriter writer
protected String defaultNameSpace
public XMLWriter(Writer w)
public void close() throws IOException
close
in interface XMLTagWriter
IOException
- if stream cannot be writtenpublic void openDoc()
openDoc
in interface XMLTagWriter
public void openDoc(String version, String encoding, boolean standalone)
openDoc
in interface XMLTagWriter
version
- version stringencoding
- encodingstandalone
- if XML is standalonepublic void referToDTD(String name, String pid, String ref)
referToDTD
in interface XMLTagWriter
public void referToDTD(String name, String system)
referToDTD
in interface XMLTagWriter
public void closeDoc()
closeDoc
in interface XMLTagWriter
public void printComment(String comment)
printComment
in interface XMLTagWriter
public void print(String text)
print
in interface XMLTagWriter
public void println(String text)
public void openTag(String namespace, String name)
openTag
in interface XMLTagWriter
namespace
- namespacename
- tagnamepublic void openTag(String name)
openTag
in interface XMLTagWriter
name
- tagnamepublic void closeTag()
closeTag
in interface XMLTagWriter
public void printTag(String namespace, String name)
printTag
in interface XMLTagWriter
namespace
- namespacename
- tagnamepublic void printTag(String name)
printTag
in interface XMLTagWriter
name
- tagnamepublic void setAttribute(String name, String value)
setAttribute
in interface XMLTagWriter
name
- attribute namevalue
- attribute valuepublic void setAttribute(String namespace, String name, String value)
XMLTagWriter
setAttribute
in interface XMLTagWriter
namespace
- namespacename
- attribute namevalue
- attribute valuepublic void setAttribute(String name, byte value)
XMLTagWriter
setAttribute
in interface XMLTagWriter
name
- attribute namevalue
- attribute valuepublic void setAttribute(String name, char value)
XMLTagWriter
setAttribute
in interface XMLTagWriter
name
- attribute namevalue
- attribute valuepublic void setAttribute(String name, long value)
XMLTagWriter
setAttribute
in interface XMLTagWriter
name
- attribute namevalue
- attribute valuepublic void setAttribute(String name, int value)
XMLTagWriter
setAttribute
in interface XMLTagWriter
name
- attribute namevalue
- attribute valuepublic void setAttribute(String name, short value)
XMLTagWriter
setAttribute
in interface XMLTagWriter
name
- attribute namevalue
- attribute valuepublic void setAttribute(String name, boolean value)
XMLTagWriter
setAttribute
in interface XMLTagWriter
name
- attribute namevalue
- attribute valuepublic void setAttribute(String name, float value)
XMLTagWriter
setAttribute
in interface XMLTagWriter
name
- attribute namevalue
- attribute valuepublic void setAttribute(String name, double value)
XMLTagWriter
setAttribute
in interface XMLTagWriter
name
- attribute namevalue
- attribute valuepublic void setAttribute(String name, Color value)
XMLTagWriter
setAttribute
in interface XMLTagWriter
name
- attribute namevalue
- attribute valuepublic void setAttribute(String ns, String name, byte value)
XMLTagWriter
setAttribute
in interface XMLTagWriter
ns
- namespacename
- attribute namevalue
- attribute valuepublic void setAttribute(String ns, String name, char value)
XMLTagWriter
setAttribute
in interface XMLTagWriter
ns
- namespacename
- attribute namevalue
- attribute valuepublic void setAttribute(String ns, String name, long value)
XMLTagWriter
setAttribute
in interface XMLTagWriter
ns
- namespacename
- attribute namevalue
- attribute valuepublic void setAttribute(String ns, String name, int value)
XMLTagWriter
setAttribute
in interface XMLTagWriter
ns
- namespacename
- attribute namevalue
- attribute valuepublic void setAttribute(String ns, String name, short value)
XMLTagWriter
setAttribute
in interface XMLTagWriter
ns
- namespacename
- attribute namevalue
- attribute valuepublic void setAttribute(String ns, String name, boolean value)
XMLTagWriter
setAttribute
in interface XMLTagWriter
ns
- namespacename
- attribute namevalue
- attribute valuepublic void setAttribute(String ns, String name, float value)
XMLTagWriter
setAttribute
in interface XMLTagWriter
ns
- namespacename
- attribute namevalue
- attribute valuepublic void setAttribute(String ns, String name, double value)
XMLTagWriter
setAttribute
in interface XMLTagWriter
ns
- namespacename
- attribute namevalue
- attribute valuepublic void setAttribute(String ns, String name, Color value)
XMLTagWriter
setAttribute
in interface XMLTagWriter
ns
- namespacename
- attribute namevalue
- attribute valueprotected void printAttributes(int tagLength)
public void print(Node node)
public static String normalize(String s)
protected void checkNameValid(String s)
Copyright © 2014. All rights reserved.