|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.Writer
org.jvoicexml.xml.XmlWriter
public class XmlWriter
This writer captures context used when writing XML text, such as state used to "pretty print" output or to identify entities which are defined. Pretty printing is useful when displaying structure in XML documents that need to be read or edited by people (rather than only by machines).
Copyright © 2005-2006 JVoiceXML group - http://jvoicexml.sourceforge.net/
XmlWritable| Field Summary | |
|---|---|
static int |
DEFAULT_BLOCK_INDENT
Default numberofspaces for block indent. |
static String |
EOL
The end of line terminator retrieved by evaluating the system property line.separator. |
| Fields inherited from class java.io.Writer |
|---|
lock |
| Constructor Summary | |
|---|---|
XmlWriter(Writer out)
Constructs an xml writethat doesn't pretty-print output. |
|
XmlWriter(Writer out,
int spaces)
Constructs an xml write that supports pretty-printing output with the given number of spaces for block indentation. |
|
| Method Summary | |
|---|---|
void |
close()
Close the stream, flushing it first. |
void |
decIndentLevel()
Decrease the indent level by 1, does nothing if the indent level is 0. |
void |
flush()
Flush the stream. |
int |
getBlockSpaces()
Returns the number of spaces per indent level, for use in pretty printing XML text. |
int |
getIndentLevel()
Returns the current indent level, in terms of blocks, for use in pretty printing XML text. |
Writer |
getWriter()
Returns the writer to which output should be written. |
void |
incIndentLevel()
Increase the indent level by 1. |
boolean |
isEntityDeclared(String name)
Returns true if the specified entity was already declared in this output context, so that entity references may be written rather than their expanded values. |
boolean |
isPrettyOutput()
Returns true if writes using the context should "pretty print", displaying structure through indentation as appropriate. |
void |
printIndent()
If pretty printing is enabled, this writes a newline followed by indentLevel spaces. |
void |
setBlockSpaces(int spaces)
Assigns the number of spaces per indent level, for use in pretty printing XML text. |
void |
setIndentLevel(int level)
Assigns the current indent level, in terms of blocks, for use in pretty printing XML text. |
void |
write(char[] cbuf)
Write an array of characters. |
void |
write(char[] cbuf,
int off,
int len)
Write a portion of an array of characters. |
void |
write(int c)
Write a single character. |
void |
write(String str)
Write a string. |
void |
write(String str,
int off,
int len)
Write a portion of a string. |
void |
writeAttribute(String name,
String value)
Writes a attribute in the form of name="value". |
void |
writeHeader()
Write a standard header for an XML document. |
| Methods inherited from class java.io.Writer |
|---|
append, append, append |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String EOL
line.separator.
public static final int DEFAULT_BLOCK_INDENT
| Constructor Detail |
|---|
public XmlWriter(Writer out)
out - Writer to which output should be written.
public XmlWriter(Writer out,
int spaces)
out - Writer to which output should be written.spaces - Number of spaces for blocks, for
use in pretty printing XML text.| Method Detail |
|---|
public final Writer getWriter()
public final boolean isEntityDeclared(String name)
name - Name of the entity.
true if the specified entity wasalready declared.public final int getBlockSpaces()
public final void setBlockSpaces(int spaces)
spaces - Number of spaces.public final int getIndentLevel()
public final void setIndentLevel(int level)
level - New indent level.public final void incIndentLevel()
public final void decIndentLevel()
public final void printIndent()
throws IOException
indentLevel spaces. At the beginning of a line, groups
of eight consecutive spaces are replaced by tab characters, for
storage efficiency.
Note that this method should not be used except in cases
where the additional whitespace is guaranteed to be semantically
meaningless. This is the default, and is controlled through the
xml:space attribute, inherited from parent elements.
When this attribute value is preserve, this method should
not be used. Otherwise, text normalization is expected to remove
excess whitespace such as that added by this call.
IOException - Error writing to the writer.public final boolean isPrettyOutput()
true if writes should pretty print
public final void close()
throws IOException
close in interface Closeableclose in class WriterIOException - If an I/O error occurs
public final void flush()
throws IOException
flush in interface Flushableflush in class WriterIOException - If an I/O error occurs
public final void write(String str)
throws IOException
write in class Writerstr - String to be written
IOException - If an I/O error occurs
public final void write(String str,
int off,
int len)
throws IOException
write in class Writerstr - A Stringoff - Offset from which to start writing characterslen - Number of characters to write
IOException - If an I/O error occurs
public final void write(char[] cbuf)
throws IOException
write in class Writercbuf - Array of characters to be written
IOException - If an I/O error occurs
public final void write(char[] cbuf,
int off,
int len)
throws IOException
write in class Writercbuf - Array of charactersoff - Offset from which to start writing characterslen - Number of characters to write
IOException - If an I/O error occurs
public final void write(int c)
throws IOException
write in class Writerc - int specifying a character to be written.
IOException - If an I/O error occurs
public final void writeHeader()
throws IOException
IOException - Error writing to the writer
IOException - Error writing to the writer.
public final void writeAttribute(String name,
String value)
throws IOException
name="value". A leading
space is always written before the name. Does
nothing if either the name of the attribute or its value is
null.
name - Name of the attribute.value - Value of the attribute.
IOException - Error writing to the writer.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||