A support class for writing XML files.
allowLineBreak
public void allowLineBreak()
throws IOException
Forces a linebreak on the next call to writeTag or writeCloseTag.
decreaseIndent
protected void decreaseIndent()
Decreates the indention by one level.
endBlock
public void endBlock()
throws IOException
Ends the current block by decreasing the indent level.
getIndentLevel
public int getIndentLevel()
Returns the current indent level.
- the current indent level.
getLineSeparator
public static String getLineSeparator()
Returns the line separator.
increaseIndent
protected void increaseIndent()
Increases the indention by one level.
indent
public void indent(Writer writer,
int increase)
throws IOException
Indent the line. Called for proper indenting in various places.
writer
- the writer which should receive the indentention.increase
- the current indent level.
normalize
public static String normalize(String s)
Normalises a string, replacing certain characters with their escape
sequences so that the XML text is not corrupted.
startBlock
public void startBlock()
throws IOException
Starts a new block by increasing the indent level.
writeCloseTag
public void writeCloseTag(Writer w,
String tag)
throws IOException
Writes a closing XML tag.
w
- the writer.tag
- the tag name.
writeTag
public void writeTag(Writer w,
String name)
throws IOException
Writes an opening XML tag that has no attributes.
w
- the writer.name
- the tag name.
writeTag
public void writeTag(Writer w,
String name,
Properties attributes,
boolean close)
throws IOException
use the attribute list instead of the properties.
Writes an opening XML tag along with a list of attribute/value pairs.
w
- the writer.name
- the tag name.attributes
- the attributes.close
- controls whether the tag is closed.
writeTag
public void writeTag(Writer w,
String name,
String attributeName,
String attributeValue,
boolean close)
throws IOException
Writes an opening XML tag with an attribute/value pair.
w
- the writer.name
- the tag name.attributeName
- the attribute name.attributeValue
- the attribute value.close
- controls whether the tag is closed.
writeTag
public void writeTag(Writer w,
String name,
AttributeList attributes,
boolean close)
throws IOException
Writes an opening XML tag along with a list of attribute/value pairs.
w
- the writer.name
- the tag name.attributes
- the attributes.close
- controls whether the tag is closed.