Tabnine Logo
IoBuffer.getInt
Code IndexAdd Tabnine to your IDE (free)

How to use
getInt
method
in
org.apache.mina.codec.IoBuffer

Best Java code snippets using org.apache.mina.codec.IoBuffer.getInt (Showing top 9 results out of 315)

origin: apache/mina

/**
 * @see ByteBuffer#getInt()
 */
public int getInt() {
  return getInt(position);
}
origin: apache/mina

private float getFloat(Pointer pos) {
  return Float.intBitsToFloat(getInt(pos));
}
origin: apache/mina

/**
 * @see ByteBuffer#getInt(int)
 */
public int getInt(int index) {
  return getInt(getPointerByPosition(index));
}
origin: apache/mina

/**
 * Test the getInt() method, on a buffer containing 1 incomplet int spread
 * in two ByteBuffers
 */
@Test(expected = BufferUnderflowException.class)
public void testGetIntIncompletInt2BBs() {
  ByteBuffer bb1 = ByteBuffer.allocate(1);
  bb1.put((byte) 0x01);
  bb1.flip();
  ByteBuffer bb2 = ByteBuffer.allocate(2);
  bb2.put(new byte[] { 0x02, 0x03 });
  bb2.flip();
  IoBuffer ioBuffer = IoBuffer.wrap(bb1, bb2);
  ioBuffer.getInt();
}
origin: apache/mina

/**
 * Test the getInt() method, on a buffer containing 2 ints in one ByteBuffer
 */
@Test
public void testGetInt2IntsOneBB() {
  ByteBuffer bb = ByteBuffer.allocate(8);
  bb.putInt(12345);
  bb.putInt(67890);
  bb.flip();
  IoBuffer ioBuffer = IoBuffer.wrap(bb);
  assertEquals(12345, ioBuffer.getInt());
  assertEquals(67890, ioBuffer.getInt());
}
origin: apache/mina

/**
 * Test the getInt() method, on a buffer containing 2 ints in two
 * ByteBuffers
 */
@Test
public void testGetInt2Ints2BBs() {
  ByteBuffer bb1 = ByteBuffer.allocate(4);
  bb1.putInt(12345);
  bb1.flip();
  ByteBuffer bb2 = ByteBuffer.allocate(4);
  bb2.putInt(67890);
  bb2.flip();
  IoBuffer ioBuffer = IoBuffer.wrap(bb1, bb2);
  assertEquals(12345, ioBuffer.getInt());
  assertEquals(67890, ioBuffer.getInt());
}
origin: apache/mina

/**
 * Test the getInt() method, on a buffer containing 1 int spread in two
 * ByteBuffers
 */
@Test
public void testGetInt1Int2BBs() {
  ByteBuffer bb1 = ByteBuffer.allocate(1);
  bb1.put((byte) 0x01);
  bb1.flip();
  ByteBuffer bb2 = ByteBuffer.allocate(3);
  bb2.put(new byte[] { 0x02, 0x03, 0x04 });
  bb2.flip();
  IoBuffer ioBuffer = IoBuffer.wrap(bb1, bb2);
  assertEquals(0x01020304, ioBuffer.getInt());
}
origin: apache/mina

/**
 * Test the getInt() method, on a buffer containing 2 ints in two
 * ByteBuffers with LittleInidan order
 */
@Test
public void testGetInt2Ints2BBsLittleIndian() {
  ByteBuffer bb1 = ByteBuffer.allocate(4);
  bb1.order(ByteOrder.LITTLE_ENDIAN);
  bb1.putInt(12345);
  bb1.flip();
  ByteBuffer bb2 = ByteBuffer.allocate(4);
  bb2.order(ByteOrder.LITTLE_ENDIAN);
  bb2.putInt(67890);
  bb2.flip();
  IoBuffer ioBuffer = IoBuffer.wrap(bb1, bb2);
  ioBuffer.order(ByteOrder.LITTLE_ENDIAN);
  assertEquals(12345, ioBuffer.getInt());
  assertEquals(67890, ioBuffer.getInt());
}
origin: apache/mina

@Test
public void testInt() {
  for (ByteOrder bo : new ByteOrder[] { ByteOrder.BIG_ENDIAN, ByteOrder.LITTLE_ENDIAN }) {
    ByteBuffer bb = (ByteBuffer) ByteBuffer.allocate(5).order(bo).putInt(123456).rewind();
    IoBuffer ioBuffer = IoBuffer.wrap(bb).order(bo);
    assertEquals(5, ioBuffer.capacity());
    ioBuffer.extend(3);
    ioBuffer.position(4);
    assertEquals(8, ioBuffer.capacity());
    ioBuffer.putInt(-23456789);
    ioBuffer.rewind();
    assertEquals(123456, ioBuffer.getInt());
    assertEquals(-23456789, ioBuffer.getInt());
    ioBuffer.rewind();
    ioBuffer.putInt(2, 1234567890);
    assertEquals(1234567890, ioBuffer.getInt(2));
    try {
      ioBuffer.putInt(5, 1);
      fail("Not enough place on the buffer");
    } catch (BufferUnderflowException e) {
      // Should come here
    }
    try {
      ioBuffer.getInt(5);
      fail("Not enough place on the buffer");
    } catch (BufferUnderflowException e) {
      // Should come here
    }
  }
}
org.apache.mina.codecIoBuffergetInt

Popular methods of IoBuffer

  • asInputStream
    Provides an input stream which is actually reading the IoBufferinstance. Further reads on the return
  • get
  • remaining
  • add
    Add one or more ByteBuffer to the current IoBuffer
  • array
  • capacity
  • getChar
  • getDouble
  • getFloat
  • getLong
  • getShort
  • hasRemaining
  • getShort,
  • hasRemaining,
  • isDirect,
  • limit,
  • order,
  • position,
  • put,
  • putChar,
  • putDouble

Popular in Java

  • Making http requests using okhttp
  • getContentResolver (Context)
  • compareTo (BigDecimal)
  • runOnUiThread (Activity)
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • JButton (javax.swing)
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now