Package org.tmatesoft.sqljet.core.internal

Examples of org.tmatesoft.sqljet.core.internal.ISqlJetMemoryBuffer


     * (int,
     * org.tmatesoft.sqljet.core.sandbox.memory.ISqlJetMemoryManager.BufferType)
     */
    public ISqlJetMemoryBuffer allocate(int size, SqlJetMemoryBufferType bufferType) {
        if (size >= 0) {
            final ISqlJetMemoryBuffer buffer;
            switch (bufferType) {
            case ARRAY:
                buffer = new SqlJetByteArrayBuffer();
                break;
            case BUFFER:
                buffer = new SqlJetByteBuffer();
                break;
            case DIRECT:
                buffer = new SqlJetDirectByteBuffer();
                break;
            default:
                buffer = new SqlJetByteArrayBuffer();
            }
            buffer.allocate(size);
            return buffer;
        } else {
            return null;
        }
    }
View Full Code Here


    private static final ISqlJetMemoryManager memoryManager = new SqlJetMemoryManager();

    @Test
    public void testByteArray() {
        ISqlJetMemoryBuffer b = memoryManager.allocate(ISqlJetMemoryManager.BYTE_SIZE, SqlJetMemoryBufferType.ARRAY);
        b.putByte(0, (byte) 1);
        Assert.assertEquals(1, b.getByte(0));
        b.putByte(0, (byte) -1);
        Assert.assertEquals(-1, b.getByte(0));
        b.putByte(0, Byte.MAX_VALUE);
        Assert.assertEquals(Byte.MAX_VALUE, b.getByte(0));
        b.putByte(0, Byte.MIN_VALUE);
        Assert.assertEquals(Byte.MIN_VALUE, b.getByte(0));
        memoryManager.free(b);
    }
View Full Code Here

        memoryManager.free(b);
    }

    @Test
    public void testUnsignedByteArray() {
        ISqlJetMemoryBuffer b = memoryManager.allocate(ISqlJetMemoryManager.BYTE_SIZE, SqlJetMemoryBufferType.ARRAY);
        b.putByteUnsigned(0, 0xFF);
        Assert.assertEquals(0xFF, b.getByteUnsigned(0));
        b.putByteUnsigned(0, (byte) 1);
        Assert.assertEquals(1, b.getByteUnsigned(0));
        Assert.assertEquals(1, b.getByte(0));
        b.putByte(0, (byte) 1);
        Assert.assertEquals(1, b.getByteUnsigned(0));
        Assert.assertEquals(1, b.getByte(0));
        memoryManager.free(b);
    }
View Full Code Here

        memoryManager.free(b);
    }

    @Test
    public void testShortArray() {
        ISqlJetMemoryBuffer b = memoryManager.allocate(ISqlJetMemoryManager.SHORT_SIZE, SqlJetMemoryBufferType.ARRAY);
        b.putShort(0, (short) 1);
        Assert.assertEquals(1, b.getShort(0));
        b.putShort(0, (short) -1);
        Assert.assertEquals(-1, b.getShort(0));
        b.putShort(0, Short.MAX_VALUE);
        Assert.assertEquals(Short.MAX_VALUE, b.getShort(0));
        b.putShort(0, Short.MIN_VALUE);
        Assert.assertEquals(Short.MIN_VALUE, b.getShort(0));
        memoryManager.free(b);
    }
View Full Code Here

        memoryManager.free(b);
    }

    @Test
    public void testUnsignedShortArray() {
        ISqlJetMemoryBuffer b = memoryManager.allocate(ISqlJetMemoryManager.SHORT_SIZE, SqlJetMemoryBufferType.ARRAY);
        b.putShortUnsigned(0, 0xFFFF);
        Assert.assertEquals(0xFFFF, b.getShortUnsigned(0));
        b.putShortUnsigned(0, (short) 1);
        Assert.assertEquals(1, b.getShortUnsigned(0));
        Assert.assertEquals(1, b.getShort(0));
        b.putShort(0, (short) 1);
        Assert.assertEquals(1, b.getShortUnsigned(0));
        Assert.assertEquals(1, b.getShort(0));
        memoryManager.free(b);
    }
View Full Code Here

        memoryManager.free(b);
    }

    @Test
    public void testIntArray() {
        ISqlJetMemoryBuffer b = memoryManager.allocate(ISqlJetMemoryManager.INT_SIZE, SqlJetMemoryBufferType.ARRAY);
        b.putInt(0, 1);
        Assert.assertEquals(1, b.getInt(0));
        b.putInt(0, -1);
        Assert.assertEquals(-1, b.getInt(0));
        b.putInt(0, Integer.MAX_VALUE);
        Assert.assertEquals(Integer.MAX_VALUE, b.getInt(0));
        b.putInt(0, Integer.MIN_VALUE);
        Assert.assertEquals(Integer.MIN_VALUE, b.getInt(0));
        memoryManager.free(b);
    }
View Full Code Here

        memoryManager.free(b);
    }

    @Test
    public void testUnsignedIntArray() {
        ISqlJetMemoryBuffer b = memoryManager.allocate(ISqlJetMemoryManager.INT_SIZE, SqlJetMemoryBufferType.ARRAY);
        b.putIntUnsigned(0, 0xFFFFFFFFL);
        Assert.assertEquals(0xFFFFFFFFL, b.getIntUnsigned(0));
        b.putIntUnsigned(0, 1);
        Assert.assertEquals(1, b.getIntUnsigned(0));
        Assert.assertEquals(1, b.getInt(0));
        b.putInt(0, 1);
        Assert.assertEquals(1, b.getIntUnsigned(0));
        Assert.assertEquals(1, b.getInt(0));
        memoryManager.free(b);
    }
View Full Code Here

        memoryManager.free(b);
    }

    @Test
    public void testByteBuffer() {
        ISqlJetMemoryBuffer b = memoryManager.allocate(ISqlJetMemoryManager.BYTE_SIZE, SqlJetMemoryBufferType.BUFFER);
        b.putByte(0, (byte) 1);
        Assert.assertEquals(1, b.getByte(0));
        b.putByte(0, (byte) -1);
        Assert.assertEquals(-1, b.getByte(0));
        b.putByte(0, Byte.MAX_VALUE);
        Assert.assertEquals(Byte.MAX_VALUE, b.getByte(0));
        b.putByte(0, Byte.MIN_VALUE);
        Assert.assertEquals(Byte.MIN_VALUE, b.getByte(0));
        memoryManager.free(b);
    }
View Full Code Here

        memoryManager.free(b);
    }

    @Test
    public void testUnsignedByteBuffer() {
        ISqlJetMemoryBuffer b = memoryManager.allocate(ISqlJetMemoryManager.BYTE_SIZE, SqlJetMemoryBufferType.BUFFER);
        b.putByteUnsigned(0, 0xFF);
        Assert.assertEquals(0xFF, b.getByteUnsigned(0));
        b.putByteUnsigned(0, (byte) 1);
        Assert.assertEquals(1, b.getByteUnsigned(0));
        Assert.assertEquals(1, b.getByte(0));
        b.putByte(0, (byte) 1);
        Assert.assertEquals(1, b.getByteUnsigned(0));
        Assert.assertEquals(1, b.getByte(0));
        memoryManager.free(b);
    }
View Full Code Here

        memoryManager.free(b);
    }

    @Test
    public void testShortBuffer() {
        ISqlJetMemoryBuffer b = memoryManager.allocate(ISqlJetMemoryManager.SHORT_SIZE, SqlJetMemoryBufferType.BUFFER);
        b.putShort(0, (short) 1);
        Assert.assertEquals(1, b.getShort(0));
        b.putShort(0, (short) -1);
        Assert.assertEquals(-1, b.getShort(0));
        b.putShort(0, Short.MAX_VALUE);
        Assert.assertEquals(Short.MAX_VALUE, b.getShort(0));
        b.putShort(0, Short.MIN_VALUE);
        Assert.assertEquals(Short.MIN_VALUE, b.getShort(0));
        memoryManager.free(b);
    }
View Full Code Here

TOP

Related Classes of org.tmatesoft.sqljet.core.internal.ISqlJetMemoryBuffer

Copyright © 2018 www.massapicom. 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.