@Override protected void _releaseBuffers() { _buffer.clear(); }
@Override protected void _releaseBuffers() { _buffer.clear(); }
/** * Creates a dynamic buffer with the given byte order and * the given initial buffer size. * @param order the byte order * @param initialSize the initial buffer size */ public DynamicOutputBuffer(ByteOrder order, int initialSize) { if (initialSize <= 0) { throw new IllegalArgumentException("Initial buffer size must be larger than 0"); } _order = order; _bufferSize = initialSize; clear(); }
/** * Creates a dynamic buffer with the given byte order and * the given initial buffer size. * @param order the byte order * @param initialSize the initial buffer size */ public DynamicOutputBuffer(ByteOrder order, int initialSize) { if (initialSize <= 0) { throw new IllegalArgumentException("Initial buffer size must be larger than 0"); } _order = order; _bufferSize = initialSize; clear(); }
@Override public void flush() throws IOException { //we must not flush the buffer if we are currently writing a document //otherwise we cannot write the document size to the header at the end if (_currentDocument == null) { _buffer.writeTo(_out); _buffer.clear(); } _out.flush(); }
@Override public void flush() throws IOException { //we must not flush the buffer if we are currently writing a document //otherwise we cannot write the document size to the header at the end if (_currentDocument == null) { _buffer.writeTo(_out); _buffer.clear(); } _out.flush(); }
@Override public void close() throws IOException { //finish document if (isEnabled(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT)) { while (_currentDocument != null) { writeEndObject(); } } //write buffer to output stream (if streaming is enabled, //this will write the the rest of the buffer) _buffer.writeTo(_out); _buffer.clear(); _out.flush(); if (isEnabled(JsonGenerator.Feature.AUTO_CLOSE_TARGET)) { _out.close(); } super.close(); }
@Override public void close() throws IOException { //finish document if (isEnabled(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT)) { while (_currentDocument != null) { writeEndObject(); } } //write buffer to output stream (if streaming is enabled, //this will write the the rest of the buffer) _buffer.writeTo(_out); _buffer.clear(); _out.flush(); if (isEnabled(JsonGenerator.Feature.AUTO_CLOSE_TARGET)) { _out.close(); } super.close(); }