Codota Logo
CompositeBuffer.toByteBufferArray
Code IndexAdd Codota to your IDE (free)

How to use
toByteBufferArray
method
in
org.glassfish.grizzly.memory.CompositeBuffer

Best Java code snippets using org.glassfish.grizzly.memory.CompositeBuffer.toByteBufferArray (Showing top 14 results out of 315)

  • Common ways to obtain CompositeBuffer
private void myMethod () {
CompositeBuffer c =
  • Codota IconCompositeBuffer.newBuffer()
  • Codota IconMemoryManager memoryManager;CompositeBuffer.newBuffer(memoryManager)
  • Codota IconBuffersBuffer.create()
  • Smart code suggestions by Codota
}
origin: javaee/grizzly

public static int readCompositeBuffer(final TCPNIOConnection connection,
    final CompositeBuffer buffer) throws IOException {
  
  final SocketChannel socketChannel = (SocketChannel) connection.getChannel();
  final int oldPos = buffer.position();
  final ByteBufferArray array = buffer.toByteBufferArray();
  final ByteBuffer byteBuffers[] = array.getArray();
  final int size = array.size();
  
  final int read = (int) socketChannel.read(byteBuffers, 0, size);
  array.restore();
  array.recycle();
  
  if (read > 0) {
    buffer.position(oldPos + read);
  }
  
  if (LOGGER.isLoggable(Level.FINE)) {
    LOGGER.log(Level.FINE, "TCPNIOConnection ({0}) (nonallocated, composite) read {1} bytes", new Object[]{
          connection, read
        });
  }
  
  return read;
}
origin: javaee/grizzly

public static int readCompositeBuffer(final TCPNIOConnection connection,
    final CompositeBuffer buffer) throws IOException {
  
  final SocketChannel socketChannel = (SocketChannel) connection.getChannel();
  final int oldPos = buffer.position();
  final ByteBufferArray array = buffer.toByteBufferArray();
  final ByteBuffer byteBuffers[] = array.getArray();
  final int size = array.size();
  
  final int read = (int) socketChannel.read(byteBuffers, 0, size);
  array.restore();
  array.recycle();
  
  if (read > 0) {
    buffer.position(oldPos + read);
  }
  
  if (LOGGER.isLoggable(Level.FINE)) {
    LOGGER.log(Level.FINE, "TCPNIOConnection ({0}) (nonallocated, composite) read {1} bytes", new Object[]{
          connection, read
        });
  }
  
  return read;
}
origin: javaee/grizzly

public static int readCompositeBuffer(final TCPNIOConnection connection,
    final CompositeBuffer buffer) throws IOException {
  
  final SocketChannel socketChannel = (SocketChannel) connection.getChannel();
  final int oldPos = buffer.position();
  final ByteBufferArray array = buffer.toByteBufferArray();
  final ByteBuffer byteBuffers[] = array.getArray();
  final int size = array.size();
  
  final int read = (int) socketChannel.read(byteBuffers, 0, size);
  array.restore();
  array.recycle();
  
  if (read > 0) {
    buffer.position(oldPos + read);
  }
  
  if (LOGGER.isLoggable(Level.FINE)) {
    LOGGER.log(Level.FINE, "TCPNIOConnection ({0}) (nonallocated, composite) read {1} bytes", new Object[]{
          connection, read
        });
  }
  
  return read;
}
origin: javaee/grizzly

public static int readCompositeBuffer(final TCPNIOConnection connection,
    final CompositeBuffer buffer) throws IOException {
  
  final SocketChannel socketChannel = (SocketChannel) connection.getChannel();
  final int oldPos = buffer.position();
  final ByteBufferArray array = buffer.toByteBufferArray();
  final ByteBuffer byteBuffers[] = array.getArray();
  final int size = array.size();
  
  final int read = (int) socketChannel.read(byteBuffers, 0, size);
  array.restore();
  array.recycle();
  
  if (read > 0) {
    buffer.position(oldPos + read);
  }
  
  if (LOGGER.isLoggable(Level.FINE)) {
    LOGGER.log(Level.FINE, "TCPNIOConnection ({0}) (nonallocated, composite) read {1} bytes", new Object[]{
          connection, read
        });
  }
  
  return read;
}
origin: javaee/grizzly

public static int readCompositeBuffer(final TCPNIOConnection connection,
    final CompositeBuffer buffer) throws IOException {
  
  final SocketChannel socketChannel = (SocketChannel) connection.getChannel();
  final int oldPos = buffer.position();
  final ByteBufferArray array = buffer.toByteBufferArray();
  final ByteBuffer byteBuffers[] = array.getArray();
  final int size = array.size();
  
  final int read = (int) socketChannel.read(byteBuffers, 0, size);
  array.restore();
  array.recycle();
  
  if (read > 0) {
    buffer.position(oldPos + read);
  }
  
  if (LOGGER.isLoggable(Level.FINE)) {
    LOGGER.log(Level.FINE, "TCPNIOConnection ({0}) (nonallocated, composite) read {1} bytes", new Object[]{
          connection, read
        });
  }
  
  return read;
}
origin: org.mule.glassfish.grizzly/grizzly-framework

public static int readCompositeBuffer(final TCPNIOConnection connection,
    final CompositeBuffer buffer) throws IOException {
  
  final SocketChannel socketChannel = (SocketChannel) connection.getChannel();
  final int oldPos = buffer.position();
  final ByteBufferArray array = buffer.toByteBufferArray();
  final ByteBuffer byteBuffers[] = array.getArray();
  final int size = array.size();
  
  final int read = (int) socketChannel.read(byteBuffers, 0, size);
  array.restore();
  array.recycle();
  
  if (read > 0) {
    buffer.position(oldPos + read);
  }
  
  if (LOGGER.isLoggable(Level.FINE)) {
    LOGGER.log(Level.FINE, "TCPNIOConnection ({0}) (nonallocated, composite) read {1} bytes", new Object[]{
          connection, read
        });
  }
  
  return read;
}
origin: org.glassfish.grizzly/grizzly-websockets-server

public static int readCompositeBuffer(final TCPNIOConnection connection,
    final CompositeBuffer buffer) throws IOException {
  
  final SocketChannel socketChannel = (SocketChannel) connection.getChannel();
  final int oldPos = buffer.position();
  final ByteBufferArray array = buffer.toByteBufferArray();
  final ByteBuffer byteBuffers[] = array.getArray();
  final int size = array.size();
  
  final int read = (int) socketChannel.read(byteBuffers, 0, size);
  array.restore();
  array.recycle();
  
  if (read > 0) {
    buffer.position(oldPos + read);
  }
  
  if (LOGGER.isLoggable(Level.FINE)) {
    LOGGER.log(Level.FINE, "TCPNIOConnection ({0}) (nonallocated, composite) read {1} bytes", new Object[]{
          connection, read
        });
  }
  
  return read;
}
origin: javaee/grizzly

public static int readCompositeBuffer(final TCPNIOConnection connection,
    final CompositeBuffer buffer) throws IOException {
  
  final SocketChannel socketChannel = (SocketChannel) connection.getChannel();
  final int oldPos = buffer.position();
  final ByteBufferArray array = buffer.toByteBufferArray();
  final ByteBuffer byteBuffers[] = array.getArray();
  final int size = array.size();
  
  final int read = (int) socketChannel.read(byteBuffers, 0, size);
  array.restore();
  array.recycle();
  
  if (read > 0) {
    buffer.position(oldPos + read);
  }
  
  if (LOGGER.isLoggable(Level.FINE)) {
    LOGGER.log(Level.FINE, "TCPNIOConnection ({0}) (nonallocated, composite) read {1} bytes", new Object[]{
          connection, read
        });
  }
  
  return read;
}
origin: javaee/grizzly

public static int readCompositeBuffer(final TCPNIOConnection connection,
    final CompositeBuffer buffer) throws IOException {
  
  final SocketChannel socketChannel = (SocketChannel) connection.getChannel();
  final int oldPos = buffer.position();
  final ByteBufferArray array = buffer.toByteBufferArray();
  final ByteBuffer byteBuffers[] = array.getArray();
  final int size = array.size();
  
  final int read = (int) socketChannel.read(byteBuffers, 0, size);
  array.restore();
  array.recycle();
  
  if (read > 0) {
    buffer.position(oldPos + read);
  }
  
  if (LOGGER.isLoggable(Level.FINE)) {
    LOGGER.log(Level.FINE, "TCPNIOConnection ({0}) (nonallocated, composite) read {1} bytes", new Object[]{
          connection, read
        });
  }
  
  return read;
}
origin: javaee/grizzly

public static int readCompositeBuffer(final TCPNIOConnection connection,
    final CompositeBuffer buffer) throws IOException {
  
  final SocketChannel socketChannel = (SocketChannel) connection.getChannel();
  final int oldPos = buffer.position();
  final ByteBufferArray array = buffer.toByteBufferArray();
  final ByteBuffer byteBuffers[] = array.getArray();
  final int size = array.size();
  
  final int read = (int) socketChannel.read(byteBuffers, 0, size);
  array.restore();
  array.recycle();
  
  if (read > 0) {
    buffer.position(oldPos + read);
  }
  
  if (LOGGER.isLoggable(Level.FINE)) {
    LOGGER.log(Level.FINE, "TCPNIOConnection ({0}) (nonallocated, composite) read {1} bytes", new Object[]{
          connection, read
        });
  }
  
  return read;
}
origin: org.glassfish.grizzly/grizzly-core

public static int readCompositeBuffer(final TCPNIOConnection connection,
    final CompositeBuffer buffer) throws IOException {
  
  final SocketChannel socketChannel = (SocketChannel) connection.getChannel();
  final int oldPos = buffer.position();
  final ByteBufferArray array = buffer.toByteBufferArray();
  final ByteBuffer byteBuffers[] = array.getArray();
  final int size = array.size();
  
  final int read = (int) socketChannel.read(byteBuffers, 0, size);
  array.restore();
  array.recycle();
  
  if (read > 0) {
    buffer.position(oldPos + read);
  }
  
  if (LOGGER.isLoggable(Level.FINE)) {
    LOGGER.log(Level.FINE, "TCPNIOConnection ({0}) (nonallocated, composite) read {1} bytes", new Object[]{
          connection, read
        });
  }
  
  return read;
}
origin: org.glassfish.grizzly/grizzly-http-server-core

public static int readCompositeBuffer(final TCPNIOConnection connection,
    final CompositeBuffer buffer) throws IOException {
  
  final SocketChannel socketChannel = (SocketChannel) connection.getChannel();
  final int oldPos = buffer.position();
  final ByteBufferArray array = buffer.toByteBufferArray();
  final ByteBuffer byteBuffers[] = array.getArray();
  final int size = array.size();
  
  final int read = (int) socketChannel.read(byteBuffers, 0, size);
  array.restore();
  array.recycle();
  
  if (read > 0) {
    buffer.position(oldPos + read);
  }
  
  if (LOGGER.isLoggable(Level.FINE)) {
    LOGGER.log(Level.FINE, "TCPNIOConnection ({0}) (nonallocated, composite) read {1} bytes", new Object[]{
          connection, read
        });
  }
  
  return read;
}
origin: javaee/grizzly

@Test
public void testToByteBufferArray() {
  final byte[] bytes = new byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
  final List<Buffer> bufferList = new ArrayList<Buffer>();
  for (byte b : bytes) {
    final Buffer buffer = mm.allocate(1);
    buffer.put(0, b);
    bufferList.add(buffer);
  }
  final Buffer[] buffers = bufferList.toArray(new Buffer[bufferList.size()]);
  final CompositeBuffer composite = CompositeBuffer.newBuffer(mm, buffers);
  for (int i = 0; i < bytes.length; i++) {
    for (int j = i; j < bytes.length; j++) {
      final ByteBufferArray bbArray = composite.toByteBufferArray(i, j);
      
      int bytesChecked = 0;
      final ByteBuffer[] bbs = bbArray.getArray();
      for (int k = 0; k < bbArray.size(); k++) {
        final ByteBuffer bb = bbs[k];
        while (bb.hasRemaining()) {
          final byte got = bb.get();
          assertEquals("Testcase [pos=" + i + " lim=" + j + " bytenumber=" + bytesChecked + "]", bytes[i + bytesChecked], got);
          bytesChecked++;
        }
      }
      assertEquals(j - i, bytesChecked);
      bbArray.restore();
    }
  }
}
origin: javaee/grizzly

  @Override
  public void run() {
    // Initialize memory manager
    mm.allocate(33);
    final int initialSize = mm.getReadyThreadBufferSize();
    CompositeBuffer compositeBuffer = CompositeBuffer.newBuffer(mm);
    for (int i = 0; i < 11; i++) {
      Buffer b = mm.allocate(1228);
      b.allowBufferDispose(true);
      compositeBuffer.append(b);
    }
    compositeBuffer.toByteBufferArray(0, 12280);
    compositeBuffer.limit(1228);
    compositeBuffer.shrink();
    assertEquals(initialSize - (1228 * 11 - 12280),
        mm.getReadyThreadBufferSize());
    compositeBuffer.position(compositeBuffer.limit());
    compositeBuffer.shrink();
    assertEquals(initialSize,
        mm.getReadyThreadBufferSize());
  }
};
org.glassfish.grizzly.memoryCompositeBuffertoByteBufferArray

Popular methods of CompositeBuffer

  • append
  • allowInternalBuffersDispose
  • newBuffer
  • remaining
  • allowBufferDispose
  • dispose
  • shrink
  • get
  • position
  • bulk
    Iterates over Buffer bytes from position to limit and lets BulkOperation examine/change the buffer c
  • disposeOrder
    Sets the order in which internal Buffers will be disposed.
  • limit
  • disposeOrder,
  • limit,
  • replace,
  • clear,
  • duplicate,
  • order,
  • prepend,
  • removeAll,
  • toBufferArray

Popular in Java

  • Updating database using SQL prepared statement
  • startActivity (Activity)
  • getSharedPreferences (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
    Creates and executes a periodic action that becomes enabled first after the given initial delay, and
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • Menu (java.awt)
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • URLConnection (java.net)
    The abstract class URLConnection is the superclass of all classes that represent a communications li
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now