| java.lang.Object uk.org.ponder.xml.XMLWriter
XMLWriter | public class XMLWriter (Code) | | A utility class to write XML data either raw or with XML/HTML entity
escaping. An XMLWriter wraps either an OutputStream or a Writer, and supplies
methods with similar names to Writer which escape all
mandatory XML/HTML entities, and methods named with suffix Raw
which write the data without transformation.
|
Method Summary | |
public void | close() Closes this XMLWriter object, in effect flushing it and making it unusable
for any further write operations. | public void | closeTag(String tag, int nestinglevel, boolean writtenchildren) | public void | flush() Flushes the wrapped stream. | public static String | getDefaultDeclaration() Returns the default declaration that will be written by the
writeDeclaration method. | public PrintOutputStream | getInternalWriter() | public static void | indent(int nestinglevel, PrintOutputStream writer) | final public void | write(char[] towrite, int start, int length) Writes the supplied data to the wrapped stream, escaping all mandatory
XML entities, being &, <, >, ".
NB apostrophe is no longer encoded, since this seems to give a measurable
Increase in speed. | public void | write(String towrite) Writes the supplied data to the wrapped stream, escaping all mandatory
XML/HTML entities, being &, <, >, " and '. | public void | writeDeclaration() Writes a default declaration to the wrapped stream. | final public static void | writeEntity(char c, PrintOutputStream pos) | public void | writeRaw(char[] towrite, int start, int length) Writes the supplied data to the wrapped stream without conversion. | public XMLWriter | writeRaw(String tag) Writes the supplied string to the wrapped stream without conversion. | public void | writeRaw(String tag, int nestinglevel) Writes the supplied string to the wrapped stream with the specified indent
level. | final public void | writeSlow(char[] towrite, int start, int length) |
DEFAULT_ENCODING | final public static String DEFAULT_ENCODING(Code) | | The default encoding to be used when writing byte streams - currently the
UTF-8 encoding
|
INDENT_WIDTH | final public static int INDENT_WIDTH(Code) | | The number of characters to indent by for each nesting level of a tag to be
written. Some writeRaw methods accept a nesting level used
as a multiplier for this factor.
|
XMLWriter | public XMLWriter(OutputStream os)(Code) | | Creates an XMLWriter wrapping the supplied OutputStream. Character data is
converted using the default encoding scheme above
Parameters: os - The output stream to be wrapped. |
XMLWriter | public XMLWriter(Writer internalwriter)(Code) | | Creates an XMLWriter wrapping the supplied Writer.
Parameters: internalwriter - The writer to be wrapped. |
close | public void close()(Code) | | Closes this XMLWriter object, in effect flushing it and making it unusable
for any further write operations.
Closing this does not close the underlying input stream!
exception: IOException - If an I/O error occurs while closing the stream. |
closeTag | public void closeTag(String tag, int nestinglevel, boolean writtenchildren)(Code) | | |
flush | public void flush()(Code) | | Flushes the wrapped stream.
exception: IOException - If an I/O error occurs while flushing the stream. |
getDefaultDeclaration | public static String getDefaultDeclaration()(Code) | | Returns the default declaration that will be written by the
writeDeclaration method.
The required default declaration. |
write | final public void write(char[] towrite, int start, int length)(Code) | | Writes the supplied data to the wrapped stream, escaping all mandatory
XML entities, being &, <, >, ".
NB apostrophe is no longer encoded, since this seems to give a measurable
Increase in speed. (' is
escaped to ' since HTML 4.0 does not define the ' entity
and does not plan to)
Parameters: towrite - A character array holding the data to be written. Parameters: start - The offset of the data to be written within the array. Parameters: length - The length of the data to be written. |
write | public void write(String towrite)(Code) | | Writes the supplied data to the wrapped stream, escaping all mandatory
XML/HTML entities, being &, <, >, " and '. ' is
escaped to ' since HTML 4.0 does not define the ' entity
and does not plan to.
Parameters: towrite - The string to be written. exception: IOException - If an I/O error occurs while writing the string. |
writeDeclaration | public void writeDeclaration()(Code) | | Writes a default declaration to the wrapped stream.
exception: IOException - If an I/O error occurs while writing the declaration. |
writeRaw | public void writeRaw(char[] towrite, int start, int length)(Code) | | Writes the supplied data to the wrapped stream without conversion.
Parameters: towrite - A character array holding the data to be written. Parameters: start - The offset of the data to be written within the array. Parameters: length - The length of the data to be written. exception: IOException - If an I/O error occurs while writing the data. |
writeRaw | public XMLWriter writeRaw(String tag)(Code) | | Writes the supplied string to the wrapped stream without conversion.
Parameters: tag - The string to be written. exception: IOException - If an I/O error occurs while writing the string. |
writeRaw | public void writeRaw(String tag, int nestinglevel)(Code) | | Writes the supplied string to the wrapped stream with the specified indent
level.
Parameters: tag - The string to be written. Parameters: nestinglevel - The multiplier for the INDENT_WIDTH , giving thenumber of spaces to be written before the supplied string. exception: IOException - If an I/O error occurs while writing the string. |
writeSlow | final public void writeSlow(char[] towrite, int start, int length)(Code) | | |
|
|