XMLWriter is not thread safe.
For efficiency this writer buffers the input. Use flush() function
to explicitly write the data to underlying stream.
This writer is designed in such a way that it at least buffers the input to the
size specified. Unless flush is called, it guarantees that
data in chunks of size equal to or more than size specified will be written.
XMLWriter instance can be reused. setWriter() internally clears the
buffer and stores the reference to newly supplied Writer instance.
| Modifier and Type | Field and Description |
|---|---|
| private XMLStringBuffer | |
| private static final boolean | |
| private int | |
| private static final int | |
| private Writer |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Implements abstract java. Implements java. Close the stream, flushing it first. |
| private void | |
| private void | |
| public void | flush()
Implements abstract java. Implements java. Flush the stream. |
| protected Writer | |
| public void | |
| public void | |
| public void | |
| public void | write(int
int specifying a character to be written. c)Overrides java. Write a single character. |
| public void | write(char[]
Array of characters to be written cbuf)Overrides java. Write an array of characters. |
| public void | write(char[]
Array of characters cbuf, int Offset from which to start writing characters off, int Number of characters to write len)Implements abstract java. Write a portion of an array of characters. |
| public void | write(String
A String str, int Offset from which to start writing characters off, int Number of characters to write len)Overrides java. Write a portion of a string. |
| public void | |
| private void |
| buffer | back to summary |
|---|---|
| private XMLStringBuffer buffer | |
| DEBUG | back to summary |
|---|---|
| private static final boolean DEBUG | |
| size | back to summary |
|---|---|
| private int size | |
| THRESHHOLD_LENGTH | back to summary |
|---|---|
| private static final int THRESHHOLD_LENGTH | |
| writer | back to summary |
|---|---|
| private Writer writer | |
| XMLWriter | back to summary |
|---|---|
| public XMLWriter(Writer writer) Creates the instance of | |
| XMLWriter | back to summary |
|---|---|
| public XMLWriter(Writer writer, int size) Creates the instance of | |
| close | back to summary |
|---|---|
| public void close() throws IOException Implements abstract java. Implements java. Close the stream, flushing it first. Once a stream has been closed, further write() or flush() invocations will cause an IOException to be thrown. Closing a previously-closed stream, however, has no effect.
| |
| conditionalWrite | back to summary |
|---|---|
| private void conditionalWrite() throws IOException write the buffer data, if the buffer size has increased the size specified | |
| ensureOpen | back to summary |
|---|---|
| private void ensureOpen() throws IOException Check to make sure that the stream has not been closed | |
| flush | back to summary |
|---|---|
| public void flush() throws IOException Implements abstract java. Implements java. Flush the stream. If the stream has saved any characters from the various write() methods in a buffer, write them immediately to their intended destination. Then, if that destination is another character or byte stream, flush it. Thus one flush() invocation will flush all the buffers in a chain of Writers and OutputStreams.
| |
| getWriter | back to summary |
|---|---|
| protected Writer getWriter() Returns underlying | |
| reset | back to summary |
|---|---|
| public void reset() Reset this Writer. see @setWriter() | |
| setWriter | back to summary |
|---|---|
| public void setWriter(Writer writer) Set the given | |
| setWriter | back to summary |
|---|---|
| public void setWriter(Writer writer, int size) Set the given | |
| write | back to summary |
|---|---|
| public void write(int c) throws IOException Overrides java. Write a single character. The character to be written is contained in the 16 low-order bits of the given integer value; the 16 high-order bits are ignored. Subclasses that intend to support efficient single-character output should override this method.
| |
| write | back to summary |
|---|---|
| public void write(char[] cbuf) throws IOException Overrides java. Write an array of characters.
| |
| write | back to summary |
|---|---|
| public void write(char[] cbuf, int off, int len) throws IOException Implements abstract java. Write a portion of an array of characters.
| |
| write | back to summary |
|---|---|
| public void write(String str, int off, int len) throws IOException Overrides java. Write a portion of a string.
| |
| write | back to summary |
|---|---|
| public void write(String str) throws IOException Overrides java. Write a string.
| |
| writeBufferedData | back to summary |
|---|---|
| private void writeBufferedData() throws IOException Write the data present in the buffer to the writer. buffer is cleared after write operation. | |