Package org.jfree.xml.writer
Class XMLWriterSupport
java.lang.Object
org.jfree.xml.writer.XMLWriterSupport
- Direct Known Subclasses:
XMLWriter
A support class for writing XML files.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final boolean
A constant for close.static final int
A constant for controlling the indent function.static final int
A constant for controlling the indent function.private int
The indent level for that writer.private String
The indent string.private static String
The line separator.private boolean
A flag indicating whether to force a linebreak before printing the next tag.static final boolean
A constant for open.static final int
A constant for controlling the indent function.private SafeTagList
A list of safe tags. -
Constructor Summary
ConstructorsConstructorDescriptionDefault 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
Modifier and TypeMethodDescriptionvoid
Forces a linebreak on the next call to writeTag or writeCloseTag.protected void
Decreates the indention by one level.void
endBlock()
Ends the current block by decreasing the indent level.int
Returns the current indent level.static String
Returns the line separator.Returns the list of safe tags.protected void
Increases the indention by one level.void
Indent the line.static String
Normalises a string, replacing certain characters with their escape sequences so that the XML text is not corrupted.void
Starts a new block by increasing the indent level.void
writeCloseTag
(Writer w, String tag) Writes a closing XML tag.void
Writes an opening XML tag that has no attributes.void
Writes an opening XML tag with an attribute/value pair.void
writeTag
(Writer w, String name, Properties attributes, boolean close) Deprecated.use the attribute list instead of the properties.void
writeTag
(Writer w, String name, AttributeList attributes, boolean close) Writes an opening XML tag along with a list of attribute/value pairs.
-
Field Details
-
OPEN_TAG_INCREASE
public static final int OPEN_TAG_INCREASEA constant for controlling the indent function.- See Also:
-
CLOSE_TAG_DECREASE
public static final int CLOSE_TAG_DECREASEA constant for controlling the indent function.- See Also:
-
INDENT_ONLY
public static final int INDENT_ONLYA constant for controlling the indent function.- See Also:
-
CLOSE
public static final boolean CLOSEA constant for close.- See Also:
-
OPEN
public static final boolean OPENA constant for open.- See Also:
-
lineSeparator
The line separator. -
safeTags
A list of safe tags. -
indentLevel
private int indentLevelThe indent level for that writer. -
indentString
The indent string. -
newLineOk
private boolean newLineOkA flag indicating whether to force a linebreak before printing the next tag.
-
-
Constructor Details
-
XMLWriterSupport
public XMLWriterSupport()Default Constructor. The created XMLWriterSupport will not have no safe tags and starts with an indention level of 0. -
XMLWriterSupport
Creates a new support instance.- Parameters:
safeTags
- tags that are safe for line breaks.indentLevel
- the index level.
-
XMLWriterSupport
Creates a new support instance.- Parameters:
safeTags
- the tags that are safe for line breaks.indentLevel
- the indent level.indentString
- the indent string.
-
-
Method Details
-
startBlock
Starts a new block by increasing the indent level.- Throws:
IOException
- if an IO error occurs.
-
endBlock
Ends the current block by decreasing the indent level.- Throws:
IOException
- if an IO error occurs.
-
allowLineBreak
Forces a linebreak on the next call to writeTag or writeCloseTag.- Throws:
IOException
- if an IO error occurs.
-
getLineSeparator
Returns the line separator.- Returns:
- the line separator.
-
writeTag
Writes an opening XML tag that has no attributes.- Parameters:
w
- the writer.name
- the tag name.- Throws:
IOException
- if there is an I/O problem.
-
writeCloseTag
Writes a closing XML tag.- Parameters:
w
- the writer.tag
- the tag name.- Throws:
IOException
- if there is an I/O problem.
-
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.- Parameters:
w
- the writer.name
- the tag name.attributeName
- the attribute name.attributeValue
- the attribute value.close
- controls whether the tag is closed.- Throws:
IOException
- if there is an I/O problem.
-
writeTag
public void writeTag(Writer w, String name, Properties attributes, boolean close) throws IOException 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:
IOException
- if there is an I/O problem.
-
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.- Parameters:
w
- the writer.name
- the tag name.attributes
- the attributes.close
- controls whether the tag is closed.- Throws:
IOException
- if there is an I/O problem.
-
normalize
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.
-
indent
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:
IOException
- if writing the stream failed.
-
getIndentLevel
public int getIndentLevel()Returns the current indent level.- Returns:
- the current indent level.
-
increaseIndent
protected void increaseIndent()Increases the indention by one level. -
decreaseIndent
protected void decreaseIndent()Decreates the indention by one level. -
getSafeTags
Returns the list of safe tags.- Returns:
- The list.
-