/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* XMLWriter
*
* <code>XMLWriter</code> is not thread safe.
*
* For efficiency this writer buffers the input. Use <code>flush()</code> function
* to explicitly write the data to underlying stream.
*
* This writer is designed in such a way that it atleast buffers the input to the
* <code>size</code> specified. Unless <code>flush</code> is called, it guarantees that
* data in chunks of size equal to or more than <code>size</code> specified will be written.
*
*
* <code>XMLWriter</code> instance can be reused. <code>setWriter()</code> internally clears the
* buffer and stores the reference to newly supplied <code>Writer</code> instance.
*
* @author Neeraj Bajaj Sun Microsystems, inc.
*/
private int size ;
//keep the size of internal buffer more than 'size' required to avoid resizing
private static final boolean DEBUG = false;
/** Creates the instance of <code>XMLWriter</code>
*/
this(writer, THRESHHOLD_LENGTH);
}
/**
* Creates the instnace of <code>XMLWriter</code>.
*
* atleast buffers the input to the
* <code>size</code> specified.
*/
}
/**
* 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.
*
* <p> Subclasses that intend to support efficient single-character output
* should override this method.
*
* @param c int specifying a character to be written.
* @exception IOException If an I/O error occurs
*/
ensureOpen();
}
/**
* Write an array of characters.
*
* @param cbuf Array of characters to be written
*
* @exception IOException If an I/O error occurs
*/
}
/**
* Write a portion of an array of characters.
*
* @param cbuf Array of characters
* @param off Offset from which to start writing characters
* @param len Number of characters to write
*
* @exception IOException If an I/O error occurs
*/
ensureOpen();
//optimization: if data size to be written is more than the 'size' specified,
//do not buffer the data but write the data straight to the underlying stream
//first write the data that may be present in the buffer
//write directly to stream
}else{
}
}
/**
* Write a portion of a string.
*
* @param str A String
* @param off Offset from which to start writing characters
* @param len Number of characters to write
*
* @exception IOException If an I/O error occurs
*/
}
/**
* Write a string.
*
* @param str String to be written
*
* @exception IOException If an I/O error occurs
*/
//optimization: if data size to be written is more than the 'size' specified,
//do not buffer the data but write the data straight to the underlying stream - nb.
//first write the data that may be present in the buffer
//write directly to stream
}else{
}
}
/**
* 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.
*
* @exception IOException If an I/O error occurs
*/
//flush it first
flush();
}
/**
* 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.
*
* @exception IOException If an I/O error occurs
*/
ensureOpen();
//write current data present in the buffer
}
/** Reset this Writer.
*
* see @setWriter()
*/
public void reset(){
this.size = THRESHHOLD_LENGTH;
}
/**
* Set the given <code>Writer</code>.
*
* @param Writer Writer.
*/
this.size = THRESHHOLD_LENGTH;
}
/** Set the given <code>Writer</code>
*
* @param Writer Writer.
* @param int Writer will buffer the character data size, after that data is written to stream.
*/
}
/**
* Returns underlying <code>Writer</code>
*/
return writer;
}
/** write the buffer data, if the buffer size has increased the size specified
*/
if(DEBUG){
}
}
}
/** Write the data present in the buffer to the writer.
* buffer is cleared after write operation.
*/
}
/** Check to make sure that the stream has not been closed */
}
}