Examples of ByteBuffer


Examples of org.ajax4jsf.io.ByteBuffer

            stream.write(i);
        }

        assertEquals(255, stream.getLength());

        ByteBuffer firstBuffer = stream.getFirstBuffer();

        assertNull(firstBuffer.getNext());
        assertNull(firstBuffer.getPrevious());
        stream.reset();
        assertEquals(0, stream.getLength());
        firstBuffer = stream.getFirstBuffer();
        assertEquals(0, firstBuffer.getUsedSize());
        assertNull(firstBuffer.getNext());
        assertNull(firstBuffer.getPrevious());
    }
View Full Code Here

Examples of org.apache.directory.api.util.ByteBuffer

public class ByteBufferTest
{
    @Test
    public void testByteBufferGrowth()
    {
        ByteBuffer buf = new ByteBuffer();
        assertEquals( 10, buf.capacity() );

        for ( int ii = 0; ii < 20; ii++ )
        {
            buf.append( ii );
            assertEquals( ii, buf.get( ii ) );
            assertEquals( ii, buf.buffer()[ii] );
        }

        assertEquals( 20, buf.capacity() );
        buf.append( 20 );
        assertEquals( 30, buf.capacity() );

        // -------------------------------------------------------------------

        buf = new ByteBuffer( 5 );
        assertEquals( 5, buf.capacity() );

        for ( int ii = 0; ii < 5; ii++ )
        {
            buf.append( ii );
            assertEquals( ii, buf.get( ii ) );
            assertEquals( ii, buf.buffer()[ii] );
        }

        assertEquals( 5, buf.capacity() );
        buf.append( 5 );
        assertEquals( 10, buf.capacity() );
    }
View Full Code Here

Examples of org.apache.directory.shared.util.ByteBuffer

public class ByteBufferTest
{
    @Test
    public void testByteBufferGrowth()
    {
        ByteBuffer buf = new ByteBuffer();
        assertEquals(10, buf.capacity());
       
        for ( int ii = 0; ii < 20; ii++ )
        {
            buf.append( ii );
            assertEquals(ii, buf.get(ii));
            assertEquals(ii, buf.buffer()[ii]);
        }
       
        assertEquals(20, buf.capacity());
        buf.append( 20 );
        assertEquals(30, buf.capacity());

        // -------------------------------------------------------------------
       
        buf = new ByteBuffer( 5 );
        assertEquals(5, buf.capacity());
       
        for ( int ii = 0; ii < 5; ii++ )
        {
            buf.append( ii );
            assertEquals(ii, buf.get(ii));
            assertEquals(ii, buf.buffer()[ii]);
        }
       
        assertEquals(5, buf.capacity());
        buf.append( 5 );
        assertEquals(10, buf.capacity());
    }
View Full Code Here

Examples of org.apache.maven.surefire.util.internal.ByteBuffer

        multicastingReporter.writeMessage( b, off, len );
    }

    public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
    {
        ByteBuffer byteBuffer = new ByteBuffer( buf, off, len );
        if ( stdout )
        {
            testStdOut.add( byteBuffer );
        }
        else
View Full Code Here

Examples of org.apache.mina.common.ByteBuffer

                LineDelimiter.WINDOWS);

        CharsetEncoder encoder = Charset.forName("UTF-8").newEncoder();
        IoSession session = new DummySession();
        TestDecoderOutput out = new TestDecoderOutput();
        ByteBuffer in = ByteBuffer.allocate(16);

        // Test one decode and one output
        in.putString("ABC\r\n", encoder);
        in.flip();
        decoder.decode(session, in, out);
        Assert.assertEquals(1, out.getMessageQueue().size());
        Assert.assertEquals("ABC", out.getMessageQueue().poll());

        // Test two decode and one output
        in.clear();
        in.putString("DEF", encoder);
        in.flip();
        decoder.decode(session, in, out);
        Assert.assertEquals(0, out.getMessageQueue().size());
        in.clear();
        in.putString("GHI\r\n", encoder);
        in.flip();
        decoder.decode(session, in, out);
        Assert.assertEquals(1, out.getMessageQueue().size());
        Assert.assertEquals("DEFGHI", out.getMessageQueue().poll());

        // Test one decode and two output
        in.clear();
        in.putString("JKL\r\nMNO\r\n", encoder);
        in.flip();
        decoder.decode(session, in, out);
        Assert.assertEquals(2, out.getMessageQueue().size());
        Assert.assertEquals("JKL", out.getMessageQueue().poll());
        Assert.assertEquals("MNO", out.getMessageQueue().poll());

        // Test splitted long delimiter
        decoder = new TextLineDecoder(Charset.forName("UTF-8"),
                new LineDelimiter("\n\n\n"));
        in.clear();
        in.putString("PQR\n", encoder);
        in.flip();
        decoder.decode(session, in, out);
        Assert.assertEquals(0, out.getMessageQueue().size());
        in.clear();
        in.putString("\n", encoder);
        in.flip();
        decoder.decode(session, in, out);
        Assert.assertEquals(0, out.getMessageQueue().size());
        in.clear();
        in.putString("\n", encoder);
        in.flip();
        decoder.decode(session, in, out);
        Assert.assertEquals(1, out.getMessageQueue().size());
        Assert.assertEquals("PQR", out.getMessageQueue().poll());

        // Test splitted long delimiter which produces two output
        decoder = new TextLineDecoder(Charset.forName("UTF-8"),
                new LineDelimiter("\n\n\n"));
        in.clear();
        in.putString("PQR\n", encoder);
        in.flip();
        decoder.decode(session, in, out);
        Assert.assertEquals(0, out.getMessageQueue().size());
        in.clear();
        in.putString("\n", encoder);
        in.flip();
        decoder.decode(session, in, out);
        Assert.assertEquals(0, out.getMessageQueue().size());
        in.clear();
        in.putString("\nSTU\n\n\n", encoder);
        in.flip();
        decoder.decode(session, in, out);
        Assert.assertEquals(2, out.getMessageQueue().size());
        Assert.assertEquals("PQR", out.getMessageQueue().poll());
        Assert.assertEquals("STU", out.getMessageQueue().poll());

        // Test splitted long delimiter mixed with partial non-delimiter.
        decoder = new TextLineDecoder(Charset.forName("UTF-8"),
                new LineDelimiter("\n\n\n"));
        in.clear();
        in.putString("PQR\n", encoder);
        in.flip();
        decoder.decode(session, in, out);
        Assert.assertEquals(0, out.getMessageQueue().size());
        in.clear();
        in.putString("X\n", encoder);
        in.flip();
        decoder.decode(session, in, out);
        Assert.assertEquals(0, out.getMessageQueue().size());
        in.clear();
        in.putString("\n\nSTU\n\n\n", encoder);
        in.flip();
        decoder.decode(session, in, out);
        Assert.assertEquals(2, out.getMessageQueue().size());
        Assert.assertEquals("PQR\nX", out.getMessageQueue().poll());
        Assert.assertEquals("STU", out.getMessageQueue().poll());
    }
View Full Code Here

Examples of org.apache.yoko.rmi.util.ByteBuffer

            try {
                int end = id.lastIndexOf(':');
                ByteString s = end < 0 ? id.substring(4) : id.substring(4, end);

                ByteBuffer bb = new ByteBuffer();

                //
                // reverse order of dot-separated name components up
                // till the first slash.
                //
                int firstSlash = s.indexOf('/');
                if (firstSlash > 0) {
                    ByteString prefix = s.substring(0, firstSlash);
                    ByteString[] elems = prefix.split('.');

                    for (int i = elems.length - 1; i >= 0; i--) {
                        bb.append(fixName(elems[i]));
                        bb.append('.');
                    }

                    s = s.substring(firstSlash + 1);
                }

                //
                // Append slash-separated name components ...
                //
                ByteString[] elems = s.split('/');
                for (int i = 0; i < elems.length; i++) {
                    bb.append(fixName(elems[i]));
                    if (i != elems.length - 1)
                        bb.append('.');
                }

                String result = bb.toString();

                logger.finer("idToClassName " + repid + " => " + result);

                return result;
            } catch (IndexOutOfBoundsException ex) {
View Full Code Here

Examples of org.asteriskjava.iax.util.ByteBuffer

    @Override
    public void convertFromLin(byte[] in, byte[] out) {

        short[] sbuff = new short[160];

        ByteBuffer bb = ByteBuffer.wrap(in);
        for (int i = 0; i < in.length / 2; i++) {
            short s = bb.getShort();
            sbuff[i] = s;
        }

        encoder.encode(sbuff, out);
View Full Code Here

Examples of org.gatein.pc.portlet.impl.jsr168.ByteBuffer

      return charBuffer.getWriter();
   }

   public OutputStream getPortletOutputStream() throws IOException
   {
      ByteBuffer byteBuffer;
      if (buffer != null)
      {
         if (buffer instanceof ByteBuffer)
         {
            byteBuffer = (ByteBuffer)buffer;
         }
         else
         {
            throw new IllegalStateException("The method getWriter() was already called");
         }
      }
      else
      {
         buffer = byteBuffer = new ByteBuffer();
      }
      return byteBuffer.getOutputStream();
   }
View Full Code Here

Examples of org.geolatte.geom.ByteBuffer

    }

    @Override
    public void setValue(PreparedStatement st, int startIndex, Geometry value) throws SQLException {
        WkbEncoder encoder = Wkb.newEncoder(Wkb.Dialect.POSTGIS_EWKB_1);
        ByteBuffer buffer = encoder.encode(value, byteOrder);
        int srid = value.getSRID();

        // prepend srid into first 4 bytes
        byte[] wkb = buffer.toByteArray();
        byte[] bytes = new byte[wkb.length + 4];
        bytes[3] = (byte) ((srid >> 24) & 0xFF);
        bytes[2] = (byte) ((srid >> 16) & 0xFF);
        bytes[1] = (byte) ((srid >> 8) & 0xFF);
        bytes[0] = (byte) (srid & 0xFF);
View Full Code Here

Examples of org.infinispan.commons.io.ByteBuffer

         connectionFactory.releaseConnection(conn);
      }
   }

   private void updateStatement(MarshalledEntry entry, String key, PreparedStatement ps) throws InterruptedException, SQLException {
      ByteBuffer byteBuffer = JdbcUtil.marshall(ctx.getMarshaller(), new KeyValuePair(entry.getValueBytes(), entry.getMetadataBytes()));
      ps.setBinaryStream(1, new ByteArrayInputStream(byteBuffer.getBuf(), byteBuffer.getOffset(), byteBuffer.getLength()), byteBuffer.getLength());
      ps.setLong(2, getExpiryTime(entry.getMetadata()));
      ps.setString(3, key);
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.