Search in sources :

Example 6 with ByteBufferInputStream

use of org.apache.geode.internal.tcp.ByteBufferInputStream in project geode by apache.

the class ByteArrayData method getDataInputStream.

public DataInputStream getDataInputStream() {
    ByteBuffer bb = ByteBuffer.wrap(this.baos.toByteArray());
    ByteBufferInputStream bbis = new ByteBufferInputStream(bb);
    return new DataInputStream(bbis);
}
Also used : ByteBufferInputStream(org.apache.geode.internal.tcp.ByteBufferInputStream) DataInputStream(java.io.DataInputStream) ByteBuffer(java.nio.ByteBuffer)

Example 7 with ByteBufferInputStream

use of org.apache.geode.internal.tcp.ByteBufferInputStream in project geode by apache.

the class PdxInstanceImpl method createDis.

private static PdxInputStream createDis(DataInput in, int len) {
    PdxInputStream dis;
    if (in instanceof PdxInputStream) {
        dis = new PdxInputStream((ByteBufferInputStream) in, len);
        try {
            int bytesSkipped = in.skipBytes(len);
            int bytesRemaining = len - bytesSkipped;
            while (bytesRemaining > 0) {
                in.readByte();
                bytesRemaining--;
            }
        } catch (IOException ex) {
            throw new PdxSerializationException("Could not deserialize PDX", ex);
        }
    } else {
        byte[] bytes = new byte[len];
        try {
            in.readFully(bytes);
        } catch (IOException ex) {
            throw new PdxSerializationException("Could not deserialize PDX", ex);
        }
        dis = new PdxInputStream(bytes);
    }
    return dis;
}
Also used : ByteBufferInputStream(org.apache.geode.internal.tcp.ByteBufferInputStream) IOException(java.io.IOException) PdxSerializationException(org.apache.geode.pdx.PdxSerializationException)

Example 8 with ByteBufferInputStream

use of org.apache.geode.internal.tcp.ByteBufferInputStream in project geode by apache.

the class ByteArrayData method getDataInput.

/**
   * Returns a <code>DataInput</code> to read from
   */
public DataInput getDataInput() {
    ByteBuffer bb = ByteBuffer.wrap(this.baos.toByteArray());
    ByteBufferInputStream bbis = new ByteBufferInputStream(bb);
    return bbis;
}
Also used : ByteBufferInputStream(org.apache.geode.internal.tcp.ByteBufferInputStream) ByteBuffer(java.nio.ByteBuffer)

Aggregations

ByteBufferInputStream (org.apache.geode.internal.tcp.ByteBufferInputStream)8 ByteBuffer (java.nio.ByteBuffer)6 DataInputStream (java.io.DataInputStream)3 IOException (java.io.IOException)2 UnitTest (org.apache.geode.test.junit.categories.UnitTest)2 Test (org.junit.Test)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInput (java.io.DataInput)1 DataOutput (java.io.DataOutput)1 DataOutputStream (java.io.DataOutputStream)1 PdxSerializationException (org.apache.geode.pdx.PdxSerializationException)1