org.jfree.xml.writer

Class XMLWriterSupport

public class XMLWriterSupport extends Object

A support class for writing XML files.

Author: Thomas Morgner

Field Summary
static booleanCLOSE
A constant for close.
static intCLOSE_TAG_DECREASE
A constant for controlling the indent function.
static intINDENT_ONLY
A constant for controlling the indent function.
static booleanOPEN
A constant for open.
static intOPEN_TAG_INCREASE
A constant for controlling the indent function.
Constructor Summary
XMLWriterSupport()
Default Constructor.
XMLWriterSupport(SafeTagList safeTags, int indentLevel)
Creates a new support instance.
XMLWriterSupport(SafeTagList safeTags, int indentLevel, String indentString)
Creates a new support instance.
Method Summary
voidallowLineBreak()
Forces a linebreak on the next call to writeTag or writeCloseTag.
protected voiddecreaseIndent()
Decreates the indention by one level.
voidendBlock()
Ends the current block by decreasing the indent level.
intgetIndentLevel()
Returns the current indent level.
static StringgetLineSeparator()
Returns the line separator.
SafeTagListgetSafeTags()
Returns the list of safe tags.
protected voidincreaseIndent()
Increases the indention by one level.
voidindent(Writer writer, int increase)
Indent the line.
static Stringnormalize(String s)
Normalises a string, replacing certain characters with their escape sequences so that the XML text is not corrupted.
voidstartBlock()
Starts a new block by increasing the indent level.
voidwriteCloseTag(Writer w, String tag)
Writes a closing XML tag.
voidwriteTag(Writer w, String name)
Writes an opening XML tag that has no attributes.
voidwriteTag(Writer w, String name, String attributeName, String attributeValue, boolean close)
Writes an opening XML tag with an attribute/value pair.
voidwriteTag(Writer w, String name, Properties attributes, boolean close)
Writes an opening XML tag along with a list of attribute/value pairs.
voidwriteTag(Writer w, String name, AttributeList attributes, boolean close)
Writes an opening XML tag along with a list of attribute/value pairs.

Field Detail

CLOSE

public static final boolean CLOSE
A constant for close.

CLOSE_TAG_DECREASE

public static final int CLOSE_TAG_DECREASE
A constant for controlling the indent function.

INDENT_ONLY

public static final int INDENT_ONLY
A constant for controlling the indent function.

OPEN

public static final boolean OPEN
A constant for open.

OPEN_TAG_INCREASE

public static final int OPEN_TAG_INCREASE
A constant for controlling the indent function.

Constructor Detail

XMLWriterSupport

public XMLWriterSupport()
Default Constructor. The created XMLWriterSupport will not have no safe tags and starts with an indention level of 0.

XMLWriterSupport

public XMLWriterSupport(SafeTagList safeTags, int indentLevel)
Creates a new support instance.

Parameters: safeTags tags that are safe for line breaks. indentLevel the index level.

XMLWriterSupport

public XMLWriterSupport(SafeTagList safeTags, int indentLevel, String indentString)
Creates a new support instance.

Parameters: safeTags the tags that are safe for line breaks. indentLevel the indent level. indentString the indent string.

Method Detail

allowLineBreak

public void allowLineBreak()
Forces a linebreak on the next call to writeTag or writeCloseTag.

Throws: IOException if an IO error occurs.

decreaseIndent

protected void decreaseIndent()
Decreates the indention by one level.

endBlock

public void endBlock()
Ends the current block by decreasing the indent level.

Throws: IOException if an IO error occurs.

getIndentLevel

public int getIndentLevel()
Returns the current indent level.

Returns: the current indent level.

getLineSeparator

public static String getLineSeparator()
Returns the line separator.

Returns: the line separator.

getSafeTags

public SafeTagList getSafeTags()
Returns the list of safe tags.

Returns: The list.

increaseIndent

protected void increaseIndent()
Increases the indention by one level.

indent

public void indent(Writer writer, int increase)
Indent the line. Called for proper indenting in various places.

Parameters: writer the writer which should receive the indentention. increase the current indent level.

Throws: java.io.IOException if writing the stream failed.

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.

Parameters: s the string.

Returns: the normalised string.

startBlock

public void startBlock()
Starts a new block by increasing the indent level.

Throws: IOException if an IO error occurs.

writeCloseTag

public void writeCloseTag(Writer w, String tag)
Writes a closing XML tag.

Parameters: w the writer. tag the tag name.

Throws: java.io.IOException if there is an I/O problem.

writeTag

public void writeTag(Writer w, String name)
Writes an opening XML tag that has no attributes.

Parameters: w the writer. name the tag name.

Throws: java.io.IOException if there is an I/O problem.

writeTag

public void writeTag(Writer w, String name, String attributeName, String attributeValue, boolean close)
Writes an opening XML tag with an attribute/value pair.

Parameters: w the writer. name the tag name. attributeName the attribute name. attributeValue the attribute value. close controls whether the tag is closed.

Throws: java.io.IOException if there is an I/O problem.

writeTag

public void writeTag(Writer w, String name, Properties attributes, boolean close)

Deprecated: use the attribute list instead of the properties.

Writes an opening XML tag along with a list of attribute/value pairs.

Parameters: w the writer. name the tag name. attributes the attributes. close controls whether the tag is closed.

Throws: java.io.IOException if there is an I/O problem.

writeTag

public void writeTag(Writer w, String name, AttributeList attributes, boolean close)
Writes an opening XML tag along with a list of attribute/value pairs.

Parameters: w the writer. name the tag name. attributes the attributes. close controls whether the tag is closed.

Throws: java.io.IOException if there is an I/O problem.