throw ex; CharBuffer charBuffer = CharBuffer.allocate(byteBuffer.capacity()); encoder.reset(); encoder.decode(byteBuffer.buf(), charBuffer, false);
/** * {@inheritDoc} */ @Override public IoBuffer capacity(int newCapacity) { buf.capacity(newCapacity); return this; }
/** * {@inheritDoc} */ @Override public int capacity() { return buf.capacity(); }
/** * {@inheritDoc} */ @Override public int capacity() { return buf.capacity(); }
/** * {@inheritDoc} */ @Override public IoBuffer capacity(int newCapacity) { buf.capacity(newCapacity); return this; }
@Override public IoBuffer capacity(int newCapacity) { buf.capacity(newCapacity); return this; }
@Override public int capacity() { return buf.capacity(); }
/** * Get the total readable bytes in a file or ByteBuffer. * * @return Total readable bytes */ @Override public long getTotalBytes() { if (!useLoadBuf) { return in.capacity(); } try { return channelSize; } catch (Exception e) { log.error("Error getTotalBytes", e); return 0; } }
/** * Get the total readable bytes in a file or ByteBuffer. * * @return Total readable bytes */ @Override public long getTotalBytes() { if (!useLoadBuf) { return in.capacity(); } try { return channelSize; } catch (Exception e) { log.error("Error getTotalBytes", e); return 0; } }
private void createOutNetBuffer(int expectedRemaining) { // SSLEngine requires us to allocate unnecessarily big buffer // even for small data. *Shrug* int capacity = Math.max(expectedRemaining, sslEngine.getSession().getPacketBufferSize()); if (outNetBuffer != null) { outNetBuffer.capacity(capacity); } else { outNetBuffer = IoBuffer.allocate(capacity).minimumCapacity(0); } }
private void createOutNetBuffer(int expectedRemaining) { // SSLEngine requires us to allocate unnecessarily big buffer // even for small data. *Shrug* int capacity = Math.max(expectedRemaining, sslEngine.getSession().getPacketBufferSize()); if (outNetBuffer != null) { outNetBuffer.capacity(capacity); } else { outNetBuffer = IoBuffer.allocate(capacity).minimumCapacity(0); } }
private void createOutNetBuffer(int expectedRemaining) { // SSLEngine requires us to allocate unnecessarily big buffer // even for small data. *Shrug* int capacity = Math.max( expectedRemaining, sslEngine.getSession().getPacketBufferSize()); if (outNetBuffer != null) { outNetBuffer.capacity(capacity); } else { outNetBuffer = IoBuffer.allocate(capacity).minimumCapacity(0); } }
public CacheableImpl(IoBuffer buffer) { if (log.isDebugEnabled()) { log.debug("Buffer is direct: {} capacity: {}", buffer.isDirect(), buffer.capacity()); log.debug("Buffer limit: {} remaining: {} position: {}", new Object[] { buffer.limit(), buffer.remaining(), buffer.position() }); } bytes = new byte[buffer.capacity()]; buffer.rewind(); int i = 0; while (i < buffer.limit()) { buffer.position(i); while (buffer.remaining() > 0) { bytes[i++] = buffer.get(); } } cached = true; if (log.isDebugEnabled()) { log.debug("Buffer size: " + buffer.capacity()); } buffer = null; }
public CacheableImpl(Object obj) { IoBuffer tmp = IoBuffer.allocate(1024, true); tmp.setAutoExpand(true); tmp.putObject(obj); bytes = new byte[tmp.capacity()]; tmp.get(bytes); cached = true; tmp.free(); tmp = null; }
public CacheableImpl(Object obj) { IoBuffer tmp = IoBuffer.allocate(1024, true); tmp.setAutoExpand(true); tmp.putObject(obj); bytes = new byte[tmp.capacity()]; tmp.get(bytes); cached = true; tmp.free(); tmp = null; }
private void storeRemainingInSession(IoBuffer buf, IoSession session) { IoBuffer remainingBuf = IoBuffer.allocate(buf.capacity()); remainingBuf.setAutoExpand(true); remainingBuf.order(buf.order()); remainingBuf.put(buf); session.setAttribute(BUFFER, remainingBuf); }
private void storeRemainingInSession(IoBuffer buf, IoSession session) { final IoBuffer remainingBuf = IoBuffer.allocate(buf.capacity()).setAutoExpand(true); remainingBuf.order(buf.order()); remainingBuf.put(buf); session.setAttribute(BUFFER, remainingBuf); }
private void storeRemainingInSession(IoBuffer buf, IoSession session) { final IoBuffer remainingBuf = IoBuffer.allocate(buf.capacity()).setAutoExpand(true); remainingBuf.order(buf.order()); remainingBuf.put(buf); session.setAttribute(BUFFER, remainingBuf); }
private void storeRemainingInSession(IoBuffer buf, IoSession session) { final IoBuffer remainingBuf = IoBuffer.allocate(buf.capacity()).setAutoExpand(true); remainingBuf.order(buf.order()); remainingBuf.put(buf); session.setAttribute(BUFFER, remainingBuf); } }
private static IoBuffer buildWSDataFrameBuffer(IoBuffer buf) { IoBuffer buffer = IoBuffer.allocate(buf.limit() + 2, false); buffer.setAutoExpand(true); buffer.put((byte) 0x82); if(buffer.capacity() <= 125){ byte capacity = (byte) (buf.limit()); buffer.put(capacity); } else{ buffer.put((byte)126); buffer.putShort((short)buf.limit()); } buffer.put(buf); buffer.flip(); return buffer; }