Package java.nio

Examples of java.nio.ByteBuffer.asReadOnlyBuffer()


                           channelId);
                return;
            }
            byte[] msgBytes = msg.getBytes(msg.limit() - msg.position());
            ByteBuffer buf = ByteBuffer.wrap(msgBytes);
            channel.receivedMessage(buf.asReadOnlyBuffer());
        }

        /**
         * {@inheritDoc}
         */
 
View Full Code Here


            throw new NullPointerException("Null bufferArray argument");
        if (!(isBufferArray(bufferArray)))
            throw new IllegalArgumentException("The passed argument is not a buffer array");
        ByteBuffer bb = ((DirectDataStorages.DirectStorage)((AbstractBufferArray)bufferArray).storage).bb;
        ByteOrder o = bb.order();
        return bufferArray.isImmutable() ? bb.asReadOnlyBuffer().order(o) : bb.duplicate().order(o);
    }

    /**
     * Returns the start offset in the buffer returned by {@link #getByteBuffer(Array)} call,
     * corresponding to the first element of the passed AlgART array.
View Full Code Here

    //for the testHashCode() method of readonly subclasses
    protected void readOnlyHashCode() {
        //create a new buffer initiated with some data
        ByteBuffer buf = ByteBuffer.allocate(BUFFER_LENGTH);
        loadTestData1(buf);
        buf = buf.asReadOnlyBuffer();
        buf.clear();
        ByteBuffer readonly = buf.asReadOnlyBuffer();
        ByteBuffer duplicate = buf.duplicate();
        assertEquals(buf.hashCode(),readonly.hashCode());
        duplicate.position(buf.capacity()/2);
View Full Code Here

    public void test_read_LByteBuffer_readOnlyBuf() throws Exception {
        // regression test for Harmony-754
        ByteBuffer c = ByteBuffer.allocate(1);
        DatagramChannel channel = DatagramChannel.open();
        try{
            channel.read(c.asReadOnlyBuffer());
            fail("Should throw NotYetConnectedException");
        } catch (NotYetConnectedException e){
            // expected
        }
        channel.connect(localAddr1);
View Full Code Here

        } catch (NotYetConnectedException e){
            // expected
        }
        channel.connect(localAddr1);
        try{
            channel.read(c.asReadOnlyBuffer());
            fail("Should throw IllegalArgumentException");
        } catch (IllegalArgumentException e){
            // expected
        }
    }
View Full Code Here

  }

  @Override
  public ByteBuffer asReadOnlyByteBuffer() {
    ByteBuffer byteBuffer = ByteBuffer.wrap(toByteArray());
    return byteBuffer.asReadOnlyBuffer();
  }

  @Override
  public List<ByteBuffer> asReadOnlyByteBufferList() {
    // Walk through the list of LiteralByteString's that make up this
View Full Code Here

            MyJapi.f524bb1(MyJapi.f424bb1());
            assert (nf424bb + 1 == f424bb.asDoubleBuffer().get());

            out.println("\ncalling f531bb1(f431bb1())");
            final ByteBuffer f431bb = MyJapi.f431bb1().order(ByteOrder.nativeOrder());
            final byte nf431bb = f431bb.asReadOnlyBuffer().get();
            MyJapi.f531bb1(f431bb);
            assert (nf431bb != f431bb.asReadOnlyBuffer().get());

            out.println("\ncalling f532bb1(f432bb1())");
            final ByteBuffer f432bb = MyJapi.f432bb1().order(ByteOrder.nativeOrder());
View Full Code Here

            out.println("\ncalling f531bb1(f431bb1())");
            final ByteBuffer f431bb = MyJapi.f431bb1().order(ByteOrder.nativeOrder());
            final byte nf431bb = f431bb.asReadOnlyBuffer().get();
            MyJapi.f531bb1(f431bb);
            assert (nf431bb != f431bb.asReadOnlyBuffer().get());

            out.println("\ncalling f532bb1(f432bb1())");
            final ByteBuffer f432bb = MyJapi.f432bb1().order(ByteOrder.nativeOrder());
            final byte nf432bb = f432bb.asReadOnlyBuffer().get();
            MyJapi.f532bb1(f432bb);
View Full Code Here

            MyJapi.f531bb1(f431bb);
            assert (nf431bb != f431bb.asReadOnlyBuffer().get());

            out.println("\ncalling f532bb1(f432bb1())");
            final ByteBuffer f432bb = MyJapi.f432bb1().order(ByteOrder.nativeOrder());
            final byte nf432bb = f432bb.asReadOnlyBuffer().get();
            MyJapi.f532bb1(f432bb);
            assert (nf432bb + 1 == f432bb.asReadOnlyBuffer().get());

            out.println("\ncalling f533bb1(f433bb1())");
            final ByteBuffer f433bb = MyJapi.f433bb1().order(ByteOrder.nativeOrder());
View Full Code Here

            out.println("\ncalling f532bb1(f432bb1())");
            final ByteBuffer f432bb = MyJapi.f432bb1().order(ByteOrder.nativeOrder());
            final byte nf432bb = f432bb.asReadOnlyBuffer().get();
            MyJapi.f532bb1(f432bb);
            assert (nf432bb + 1 == f432bb.asReadOnlyBuffer().get());

            out.println("\ncalling f533bb1(f433bb1())");
            final ByteBuffer f433bb = MyJapi.f433bb1().order(ByteOrder.nativeOrder());
            final byte nf433bb = f433bb.asReadOnlyBuffer().get();
            MyJapi.f533bb1(f433bb);
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.