Package javax.sql.rowset.serial

Examples of javax.sql.rowset.serial.SerialBlob


                        if (blobObject != null) {
                            entity.dangerousSetNoCheckButFast(curField, blobObject);
                        } else {
                            if (originalObject instanceof Blob) {
                                // NOTE using SerialBlob here instead of the Blob from the database to make sure we can pass it around, serialize it, etc
                                entity.dangerousSetNoCheckButFast(curField, new SerialBlob((Blob) originalObject));
                            } else {
                                entity.dangerousSetNoCheckButFast(curField, originalObject);
                            }
                        }
                    }
View Full Code Here


                        if (blobObject != null) {
                            entity.dangerousSetNoCheckButFast(curField, blobObject);
                        } else {
                            if (originalObject instanceof Blob) {
                                // NOTE using SerialBlob here instead of the Blob from the database to make sure we can pass it around, serialize it, etc
                                entity.dangerousSetNoCheckButFast(curField, new SerialBlob((Blob) originalObject));
                            } else {
                                entity.dangerousSetNoCheckButFast(curField, originalObject);
                            }
                        }
                    }
View Full Code Here

    }

    public Blob getBlob(int i) throws SQLException {
        byte[] value = getBytes(i);

        return value == null ? null : new SerialBlob(value);

    }
View Full Code Here

            throw new SQLException();
        }
        if (params == null) {
            throw new SQLException();
        }
        params.put(Integer.valueOf(parameterIndex - 1), new SerialBlob(x));
    }
View Full Code Here

            if (type.equals(Array.class) && !(value instanceof SerialArray)) {
                return new SerialArray((Array) value);
            }

            if (type.equals(Blob.class) && !(value instanceof SerialBlob)) {
                return new SerialBlob((Blob) value);
            }

            if (type.equals(Clob.class) && !(value instanceof SerialClob)) {
                return new SerialClob((Clob) value);
            }
View Full Code Here

                    Debug.logWarning("Blob java-type used for java.lang.Object. Use java.lang.Object java-type instead.", module);
                    return blobObject;
                } else {
                    if (originalObject instanceof Blob) {
                        // NOTE using SerialBlob here instead of the Blob from the database to make sure we can pass it around, serialize it, etc
                        return new SerialBlob((Blob) originalObject);
                    } else {
                        Debug.logWarning("Blob java-type used for byte array. Use byte[] java-type instead.", module);
                        return originalObject;
                    }
                }
View Full Code Here

public class SerialBlobTest extends TestCase {

    public void testConstructorLBlob() throws Exception {
        boolean isAbnormal = false;
        MockSerialBlob mockBlob = new MockSerialBlob(isAbnormal);
        SerialBlob serialBlob = new SerialBlob(mockBlob);
        // SerialBlob constructor initiliases with the data of given blob,
        // therefore, blob.getBytes is invoked.
        assertTrue(mockBlob.isGetBytesInvoked);
        assertEquals(1, serialBlob.length());

        isAbnormal = true;
        mockBlob = new MockSerialBlob(isAbnormal);
        try {
            new SerialBlob(mockBlob);
            fail("should throw SQLException");
        } catch (SQLException e) {
            // expected
        }

        try {
            new SerialBlob((Blob) null);
            fail("should throw SQLException");
        } catch (SQLException e) {
            // expected
        }
    }
View Full Code Here

        }
    }

    public void testConstructor$B() throws Exception {
        byte[] buf = new byte[8];
        SerialBlob serialBlob = new SerialBlob(buf);
        assertEquals(8, serialBlob.length());

        try {
            new SerialBlob((byte[]) null);
            fail("should throw NullPointerException");
        } catch (NullPointerException e) {
            // expected
        }
    }
View Full Code Here

        }
    }

    public void testGetBinaryStream() throws Exception {
        byte[] buf = { 1, 2, 3, 4, 5, 6, 7, 8 };
        SerialBlob serialBlob = new SerialBlob(buf);
        InputStream is = serialBlob.getBinaryStream();
        int i = 0;
        while (true) {
            int b = is.read();
            if (b == -1) {
                if (i < buf.length) {
View Full Code Here

        }
    }

    public void testGetBytesJI() throws Exception {
        byte[] buf = { 1, 2, 3, 4, 5, 6, 7, 8 };
        SerialBlob serialBlob = new SerialBlob(buf);
        byte[] data = serialBlob.getBytes(1, 1);
        assertEquals(1, data.length);
        assertEquals(1, data[0]);

        data = serialBlob.getBytes(2, 3);
        assertEquals(3, data.length);
        assertEquals(2, data[0]);
        assertEquals(3, data[1]);
        assertEquals(4, data[2]);

        // Harmony-2725 RI's bug : RI throws SerialException here.
        data = serialBlob.getBytes(2, 1);
        assertEquals(1, data.length);
        assertEquals(2, data[0]);

        data = serialBlob.getBytes(1, 10);
        assertEquals(8, data.length);
        assertTrue(Arrays.equals(buf, data));

        try {
            data = serialBlob.getBytes(2, -1);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }

        try {
            data = serialBlob.getBytes(0, 2);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }

        try {
            data = serialBlob.getBytes(-1, 2);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }

        try {
            data = serialBlob.getBytes(10, 11);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }
    }
View Full Code Here

TOP

Related Classes of javax.sql.rowset.serial.SerialBlob

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.