@Override public int writableBytes() { return buffer.writableBytes(); }
@Override public int writableBytes() { return buffer.writableBytes(); }
public void readBytes(ChannelBuffer dst) { readBytes(dst, dst.writableBytes()); }
@Override public void readBytes(ChannelBuffer dst) { checkReadableBytes(dst.writableBytes()); }
public void getBytes(int index, ChannelBuffer dst) { getBytes(index, dst, dst.writableBytes()); }
public void readBytes(ChannelBuffer dst, int length) { if (length > dst.writableBytes()) { throw new IndexOutOfBoundsException("Too many bytes to be read: Need " + length + ", maximum is " + dst.writableBytes()); } readBytes(dst, dst.writerIndex(), length); dst.writerIndex(dst.writerIndex() + length); }
public void getBytes(int index, ChannelBuffer dst, int length) { if (length > dst.writableBytes()) { throw new IndexOutOfBoundsException("Too many bytes to be read: Need " + length + ", maximum is " + dst.writableBytes()); } getBytes(index, dst, dst.writerIndex(), length); dst.writerIndex(dst.writerIndex() + length); }
private boolean compressInto(ChannelBuffer compressed) { byte[] out = compressed.array(); int off = compressed.arrayOffset() + compressed.writerIndex(); int toWrite = compressed.writableBytes(); int numBytes = compressor.deflate(out, off, toWrite, Deflater.SYNC_FLUSH); compressed.writerIndex(compressed.writerIndex() + numBytes); return numBytes == toWrite; }
private void deflate(ChannelBuffer out) { int numBytes; if (out.hasArray()) { do { int writerIndex = out.writerIndex(); numBytes = deflater.deflate( out.array(), out.arrayOffset() + writerIndex, out.writableBytes(), Deflater.SYNC_FLUSH); out.writerIndex(writerIndex + numBytes); } while (numBytes > 0); } else { byte[] tmpOut = this.out; if (tmpOut == null) { tmpOut = this.out = new byte[8192]; } do { numBytes = deflater.deflate(tmpOut, 0, tmpOut.length, Deflater.SYNC_FLUSH); out.writeBytes(tmpOut, 0, numBytes); } while (numBytes > 0); } }
private int decompress(SpdyHeadersFrame frame) throws Exception { ensureBuffer(); byte[] out = decompressed.array(); int off = decompressed.arrayOffset() + decompressed.writerIndex(); try { int numBytes = decompressor.inflate(out, off, decompressed.writableBytes()); if (numBytes == 0 && decompressor.needsDictionary()) { try { decompressor.setDictionary(SPDY_DICT); } catch (IllegalArgumentException e) { throw INVALID_HEADER_BLOCK; } numBytes = decompressor.inflate(out, off, decompressed.writableBytes()); } decompressed.writerIndex(decompressed.writerIndex() + numBytes); super.decodeHeaderBlock(decompressed, frame); decompressed.discardReadBytes(); return numBytes; } catch (DataFormatException e) { throw INVALID_HEADER_BLOCK; } }
@Override public int writableBytes() { return buffer.writableBytes(); }
@Override public int writableBytes() { return buffer.writableBytes(); }
public int writableBytes() { return buffer.writableBytes(); }
@Override public void writeBody(ChannelBuffer buffer) throws UnrecoverablePduException, RecoverablePduException { // when this PDU was parsed, it's possible it was missing the messageId instead // of having a NULL messageId. If that's the case, the commandLength will be just // enough for the headers (and theoretically any optional TLVs). Don't try to // write the NULL byte for that case. // See special note in 4.4.2 of SMPP 3.4 spec if (!((buffer.writableBytes() == 0) && (this.messageId == null))) { ChannelBufferUtil.writeNullTerminatedString(buffer, this.messageId); } }
@Override public void writeBody(ChannelBuffer buffer) throws UnrecoverablePduException, RecoverablePduException { // when this PDU was parsed, it's possible it was missing the messageId instead // of having a NULL messageId. If that's the case, the commandLength will be just // enough for the headers (and theoretically any optional TLVs). Don't try to // write the NULL byte for that case. // See special note in 4.4.2 of SMPP 3.4 spec if (!((buffer.writableBytes() == 0) && (this.messageId == null))) { ChannelBufferUtil.writeNullTerminatedString(buffer, this.messageId); } }
@Override public void writeBody(ChannelBuffer buffer) throws UnrecoverablePduException, RecoverablePduException { // when this PDU was parsed, it's possible it was missing the messageId instead // of having a NULL messageId. If that's the case, the commandLength will be just // enough for the headers (and theoretically any optional TLVs). Don't try to // write the NULL byte for that case. // See special note in 4.4.2 of SMPP 3.4 spec if (!((buffer.writableBytes() == 0) && (this.messageId == null))) { ChannelBufferUtil.writeNullTerminatedString(buffer, this.messageId); } }
public void readBytes(ChannelBuffer dst, int length) { if (length > dst.writableBytes()) { throw new IndexOutOfBoundsException("Too many bytes to be read: Need " + length + ", maximum is " + dst.writableBytes()); } readBytes(dst, dst.writerIndex(), length); dst.writerIndex(dst.writerIndex() + length); }
@Override public void getBytes( int index, ChannelBuffer dst ) { // TODO We need a loop for this (if dst is bigger than chunk size) readNextChunkIfNeeded( dst.writableBytes() ); buffer.getBytes( index, dst ); }
@Override public void readBytes( ChannelBuffer dst ) { readNextChunkIfNeeded( dst.writableBytes() ); buffer.readBytes( dst ); }
@Override public void readBytes(ChannelBuffer dst, int length) { if (length > dst.writableBytes()) { throw new IndexOutOfBoundsException(); } readBytes(dst, dst.writerIndex(), length); dst.writerIndex(dst.writerIndex() + length); }