public class XMLWriterSupport
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static boolean |
CLOSE
A constant for close.
|
static int |
CLOSE_TAG_DECREASE
A constant for controlling the indent function.
|
static int |
INDENT_ONLY
A constant for controlling the indent function.
|
private int |
indentLevel
The indent level for that writer.
|
private java.lang.String |
indentString
The indent string.
|
private static java.lang.String |
lineSeparator
The line separator.
|
private boolean |
newLineOk
A flag indicating whether to force a linebreak before printing the next
tag.
|
static boolean |
OPEN
A constant for open.
|
static int |
OPEN_TAG_INCREASE
A constant for controlling the indent function.
|
private SafeTagList |
safeTags
A list of safe tags.
|
Constructor and Description |
---|
XMLWriterSupport()
Default Constructor.
|
XMLWriterSupport(SafeTagList safeTags,
int indentLevel)
Creates a new support instance.
|
XMLWriterSupport(SafeTagList safeTags,
int indentLevel,
java.lang.String indentString)
Creates a new support instance.
|
Modifier and Type | Method and Description |
---|---|
void |
allowLineBreak()
Forces a linebreak on the next call to writeTag or writeCloseTag.
|
protected void |
decreaseIndent()
Decreates the indention by one level.
|
void |
endBlock()
Ends the current block by decreasing the indent level.
|
int |
getIndentLevel()
Returns the current indent level.
|
static java.lang.String |
getLineSeparator()
Returns the line separator.
|
SafeTagList |
getSafeTags()
Returns the list of safe tags.
|
protected void |
increaseIndent()
Increases the indention by one level.
|
void |
indent(java.io.Writer writer,
int increase)
Indent the line.
|
static java.lang.String |
normalize(java.lang.String s)
Normalises a string, replacing certain characters with their escape
sequences so that the XML text is not corrupted.
|
void |
startBlock()
Starts a new block by increasing the indent level.
|
void |
writeCloseTag(java.io.Writer w,
java.lang.String tag)
Writes a closing XML tag.
|
void |
writeTag(java.io.Writer w,
java.lang.String name)
Writes an opening XML tag that has no attributes.
|
void |
writeTag(java.io.Writer w,
java.lang.String name,
AttributeList attributes,
boolean close)
Writes an opening XML tag along with a list of attribute/value pairs.
|
void |
writeTag(java.io.Writer w,
java.lang.String name,
java.util.Properties attributes,
boolean close)
Deprecated.
use the attribute list instead of the properties.
|
void |
writeTag(java.io.Writer w,
java.lang.String name,
java.lang.String attributeName,
java.lang.String attributeValue,
boolean close)
Writes an opening XML tag with an attribute/value pair.
|
public static final int OPEN_TAG_INCREASE
public static final int CLOSE_TAG_DECREASE
public static final int INDENT_ONLY
public static final boolean CLOSE
public static final boolean OPEN
private static java.lang.String lineSeparator
private SafeTagList safeTags
private int indentLevel
private java.lang.String indentString
private boolean newLineOk
public XMLWriterSupport()
public XMLWriterSupport(SafeTagList safeTags, int indentLevel)
safeTags
- tags that are safe for line breaks.indentLevel
- the index level.public XMLWriterSupport(SafeTagList safeTags, int indentLevel, java.lang.String indentString)
safeTags
- the tags that are safe for line breaks.indentLevel
- the indent level.indentString
- the indent string.public void startBlock() throws java.io.IOException
java.io.IOException
- if an IO error occurs.public void endBlock() throws java.io.IOException
java.io.IOException
- if an IO error occurs.public void allowLineBreak() throws java.io.IOException
java.io.IOException
- if an IO error occurs.public static java.lang.String getLineSeparator()
public void writeTag(java.io.Writer w, java.lang.String name) throws java.io.IOException
w
- the writer.name
- the tag name.java.io.IOException
- if there is an I/O problem.public void writeCloseTag(java.io.Writer w, java.lang.String tag) throws java.io.IOException
w
- the writer.tag
- the tag name.java.io.IOException
- if there is an I/O problem.public void writeTag(java.io.Writer w, java.lang.String name, java.lang.String attributeName, java.lang.String attributeValue, boolean close) throws java.io.IOException
w
- the writer.name
- the tag name.attributeName
- the attribute name.attributeValue
- the attribute value.close
- controls whether the tag is closed.java.io.IOException
- if there is an I/O problem.public void writeTag(java.io.Writer w, java.lang.String name, java.util.Properties attributes, boolean close) throws java.io.IOException
w
- the writer.name
- the tag name.attributes
- the attributes.close
- controls whether the tag is closed.java.io.IOException
- if there is an I/O problem.public void writeTag(java.io.Writer w, java.lang.String name, AttributeList attributes, boolean close) throws java.io.IOException
w
- the writer.name
- the tag name.attributes
- the attributes.close
- controls whether the tag is closed.java.io.IOException
- if there is an I/O problem.public static java.lang.String normalize(java.lang.String s)
s
- the string.public void indent(java.io.Writer writer, int increase) throws java.io.IOException
writer
- the writer which should receive the indentention.increase
- the current indent level.java.io.IOException
- if writing the stream failed.public int getIndentLevel()
protected void increaseIndent()
protected void decreaseIndent()
public SafeTagList getSafeTags()