@Override public void writeInt(final int data) throws IOException { if (isOutputBuffered) { output.ensureBufferCapacity(4); output.getBuffer().putInt(data); } else { output.write((byte) ((data >>> 24) & 0xFF)); output.write((byte) ((data >>> 16) & 0xFF)); output.write((byte) ((data >>> 8) & 0xFF)); output.write((byte) ((data) & 0xFF)); } }
/** * Cause the overflow handler to be called even if buffer is not full. */ @Override public GrizzlyFuture<Integer> flush(CompletionHandler<Integer> completionHandler) throws IOException { return output.flush(completionHandler); }
/** Create a new ByteBufferWriter. An instance maintains a current buffer * for use in writing. Whenever the current buffer is insufficient to hold * the required data, the BufferHandler is called, and the result of the * handler is the new current buffer. The handler is responsible for * the disposition of the contents of the old buffer. */ protected AbstractStreamWriter(final Connection connection, Output streamOutput) { this.connection = connection; this.output = streamOutput; this.isOutputBuffered = streamOutput.isBuffered(); }
/** * {@inheritDoc} */ @Override public void writeBooleanArray(final boolean[] data) throws IOException { for(int i=0; i<data.length; i++) { output.write((byte) (data[i] ? 1 : 0)); } }
/** * {@inheritDoc} */ @Override public GrizzlyFuture<Integer> close( CompletionHandler<Integer> completionHandler) throws IOException { if (!isClosed.getAndSet(true)) { return output.close(completionHandler); } return ReadyFutureImpl.create(0); }
/** * {@inheritDoc} */ @Override public void writeBuffer(Buffer b) throws IOException { output.write(b); }
/** * {@inheritDoc} */ @Override public GrizzlyFuture<Integer> close( CompletionHandler<Integer> completionHandler) throws IOException { if (!isClosed.getAndSet(true)) { return output.close(completionHandler); } return ReadyFutureImpl.create(0); }
@Override public void writeInt(final int data) throws IOException { if (isOutputBuffered) { output.ensureBufferCapacity(4); output.getBuffer().putInt(data); } else { output.write((byte) ((data >>> 24) & 0xFF)); output.write((byte) ((data >>> 16) & 0xFF)); output.write((byte) ((data >>> 8) & 0xFF)); output.write((byte) ((data) & 0xFF)); } }
/** * {@inheritDoc} */ @Override public void writeBuffer(Buffer b) throws IOException { output.write(b); }
/** * {@inheritDoc} */ @Override public GrizzlyFuture<Integer> close( CompletionHandler<Integer> completionHandler) throws IOException { if (!isClosed.getAndSet(true)) { return output.close(completionHandler); } return ReadyFutureImpl.create(0); }
/** Create a new ByteBufferWriter. An instance maintains a current buffer * for use in writing. Whenever the current buffer is insufficient to hold * the required data, the BufferHandler is called, and the result of the * handler is the new current buffer. The handler is responsible for * the disposition of the contents of the old buffer. */ protected AbstractStreamWriter(final Connection connection, Output streamOutput) { this.connection = connection; this.output = streamOutput; this.isOutputBuffered = streamOutput.isBuffered(); }
/** * Cause the overflow handler to be called even if buffer is not full. */ @Override public GrizzlyFuture<Integer> flush(CompletionHandler<Integer> completionHandler) throws IOException { return output.flush(completionHandler); }
@Override public void writeInt(final int data) throws IOException { if (isOutputBuffered) { output.ensureBufferCapacity(4); output.getBuffer().putInt(data); } else { output.write((byte) ((data >>> 24) & 0xFF)); output.write((byte) ((data >>> 16) & 0xFF)); output.write((byte) ((data >>> 8) & 0xFF)); output.write((byte) ((data) & 0xFF)); } }
/** * {@inheritDoc} */ @Override public void writeBooleanArray(final boolean[] data) throws IOException { for(int i=0; i<data.length; i++) { output.write((byte) (data[i] ? 1 : 0)); } }
/** * {@inheritDoc} */ @Override public GrizzlyFuture<Integer> close( CompletionHandler<Integer> completionHandler) throws IOException { if (!isClosed.getAndSet(true)) { return output.close(completionHandler); } return ReadyFutureImpl.create(0); }
/** Create a new ByteBufferWriter. An instance maintains a current buffer * for use in writing. Whenever the current buffer is insufficient to hold * the required data, the BufferHandler is called, and the result of the * handler is the new current buffer. The handler is responsible for * the disposition of the contents of the old buffer. */ protected AbstractStreamWriter(final Connection connection, Output streamOutput) { this.connection = connection; this.output = streamOutput; this.isOutputBuffered = streamOutput.isBuffered(); }