Java 类javax.sql.rowset.serial.SerialBlob 实例源码

项目:jdk8u-jdk    文件:SerialBlobTests.java   
@Test
public void test30() throws Exception {
    long expectedPos = 3; // starting offset is 1 vs 0
    byte[] pattern = new byte[]{6, 8};
    SerialBlob sb = new SerialBlob(new StubBlob());
    long pos = sb.position(pattern, 2);
    assertEquals(pos, expectedPos);
}
项目:jspare-vertx-ms-blueprint    文件:AuditFuture.java   
@SneakyThrows
public AuditFuture saveRequest(Buffer requestBuffer) {

    Audit audit = new Audit()
            .setGateway(gatewayManager.getCurrentGateway())
            .setTid(getTid())
            .setAlias(getAlias())
            .setUri(context.request().absoluteURI())
            .setHeaders(getHeaders())
            .setRequestContent(new SerialBlob(requestBuffer.getBytes()));

    persist(audit, res -> {
        if(res.succeeded()){

            createFuture.complete(res.result());
        }else{

            createFuture.fail(res.cause());
        }
    });

    return this;
}
项目:jspare-vertx-ms-blueprint    文件:AuditFuture.java   
@SneakyThrows
public void saveResponse(Record record, Buffer responseBuffer) {

    createFuture.setHandler(res -> {

        try {

            Audit audit = res.result();
            audit
                .setRecord(record.toJson())
                .setResponseCode(context.response().getStatusCode())
                .setResponseContent(new SerialBlob(Optional.ofNullable(responseBuffer)
                        .orElse(Buffer.buffer()).getBytes()
                ));

            persist(audit, this::notifyAuditResult);
        } catch (Exception e) {

            log.error("Fail to save response");
        }
    });
}
项目:jspare-vertx-ms-blueprint    文件:AuditFuture.java   
@SneakyThrows
public AuditFuture saveRequest(Buffer requestBuffer) {

    Audit audit = new Audit()
            .setGateway(gatewayManager.getCurrentGateway())
            .setTid(getTid())
            .setAlias(getAlias())
            .setUri(context.request().absoluteURI())
            .setHeaders(getHeaders())
            .setRequestContent(new SerialBlob(requestBuffer.getBytes()));

    persist(audit, res -> {
        if(res.succeeded()){

            createFuture.complete(res.result());
        }else{

            createFuture.fail(res.cause());
        }
    });

    return this;
}
项目:jspare-vertx-ms-blueprint    文件:AuditFuture.java   
@SneakyThrows
public void saveResponse(Record record, Buffer responseBuffer) {

    createFuture.setHandler(res -> {

        try {

            Audit audit = res.result();
            audit
                .setRecord(record.toJson())
                .setResponseCode(context.response().getStatusCode())
                .setResponseContent(new SerialBlob(Optional.ofNullable(responseBuffer)
                        .orElse(Buffer.buffer()).getBytes()
                ));

            persist(audit, this::notifyAuditResult);
        } catch (Exception e) {

            log.error("Fail to save response");
        }
    });
}
项目:singular-server    文件:AttachmentGCTest.java   
private void saveAttachmentEntity() throws SQLException {
    AttachmentContentEntity attachment = new AttachmentContentEntity();
    attachment.setSize(123456);
    attachment.setHashSha1("SHA-1");
    attachment.setContent(new SerialBlob("A simple blob with value".getBytes()));

    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH)-2);
    attachment.setInclusionDate(calendar.getTime());
    attachmentContentDao.insert(attachment);

    AttachmentEntity entity = new AttachmentEntity();
    entity.setCreationDate(calendar.getTime());
    entity.setHashSha1("SHA1");
    entity.setName("name");
    entity.setSize(3512);
    entity.setCodContent(attachment.getCod());

    attachmentDao.insert(entity);
}
项目:sstore-soft    文件:JDBC4ResultSet.java   
@Override
public Blob getBlob(int columnIndex) throws SQLException {
    checkColumnBounds(columnIndex);
    try {
        return new SerialBlob(table.getStringAsBytes(columnIndex - 1));
    } catch (Exception x) {
        throw SQLError.get(x);
    }
}
项目:document-management-store-app    文件:StoredDocumentControllerNoDeleteTests.java   
public StoredDocumentControllerNoDeleteTests() throws SQLException {
    documentContent = new DocumentContent(new SerialBlob("some xml".getBytes(StandardCharsets.UTF_8)));
    documentContentVersion = DocumentContentVersion.builder()
        .id(id)
        .mimeType("text/plain")
        .originalDocumentName("filename.txt")
        .storedDocument(StoredDocument.builder().id(id).folder(Folder.builder().id(id).build()).build())
        .documentContent(documentContent).build();
    storedDocument = StoredDocument.builder().id(id)
        .folder(Folder.builder().id(id).build()).documentContentVersions(
            Stream.of(documentContentVersion)
                .collect(Collectors.toList())
        ).build();
}
项目:s-store    文件:JDBC4ResultSet.java   
@Override
public Blob getBlob(int columnIndex) throws SQLException {
    checkColumnBounds(columnIndex);
    try {
        return new SerialBlob(table.getStringAsBytes(columnIndex - 1));
    } catch (Exception x) {
        throw SQLError.get(x);
    }
}
项目:ChronoBike    文件:SQLClause.java   
public String param(SerialBlob blVal)
{
    if(m_arrParams == null)
        m_arrParams = new ArrayList<ColValue>();
    ColValue colVal = new ColValueBlob("", blVal); 
    m_arrParams.add(colVal);

    return "?";
}
项目:ChronoBike    文件:SQLClause.java   
public SQLClause paramInsert(String csName, SerialBlob blVal)
{
    if(m_arrInsertParams == null)
        m_arrInsertParams = new ArrayList<ColValue>();
    ColValue colVal = new ColValueBlob(csName, blVal); 
    m_arrInsertParams.add(colVal);

    return this;
}
项目:FCat    文件:StrUtil.java   
public static Blob toBlob(String s) {
    if (s == null || "".equals(s)) {
        return null;
    } else {
        try {
            return new SerialBlob(s.getBytes());
        } catch (Exception e) {
            LOG.error(e.getMessage(), e);
        }
        return null;
    }
}
项目:FCat    文件:StrUtil.java   
public static Blob toClob(String s) {
    if (s == null || "".equals(s)) {
        return null;
    } else {
        try {
            return new SerialBlob(s.getBytes());
        } catch (Exception e) {
            LOG.error(e.getMessage(), e);
        }
        return null;
    }
}
项目:jdk8u-jdk    文件:BaseRowSetTests.java   
@DataProvider(name = "testAdvancedParameters")
private Object[][] testAdvancedParameters() throws SQLException {

    byte[] bytes = new byte[10];
    Ref aRef = new SerialRef(new StubRef("INTEGER", query));
    Array aArray = new SerialArray(new StubArray("INTEGER", new Object[1]));
    Blob aBlob = new SerialBlob(new StubBlob());
    Clob aClob = new SerialClob(new StubClob());
    Reader rdr = new StringReader(query);
    InputStream is = new StringBufferInputStream(query);;
    brs = new StubBaseRowSet();
    brs.setBytes(1, bytes);
    brs.setAsciiStream(2, is, query.length());
    brs.setRef(3, aRef);
    brs.setArray(4, aArray);
    brs.setBlob(5, aBlob);
    brs.setClob(6, aClob);
    brs.setBinaryStream(7, is, query.length());
    brs.setUnicodeStream(8, is, query.length());
    brs.setCharacterStream(9, rdr, query.length());

    return new Object[][]{
        {1, bytes},
        {2, is},
        {3, aRef},
        {4, aArray},
        {5, aBlob},
        {6, aClob},
        {7, is},
        {8, is},
        {9, rdr}
    };
}
项目:jdk8u-jdk    文件:SQLOutputImplTests.java   
@Test(enabled = true)
public void test05() throws Exception {
    Blob b = new StubBlob();
    outImpl.writeBlob(b);
    SerialBlob sb = (SerialBlob) results.get(0);
    assertTrue(Arrays.equals(
            b.getBytes(1, (int) b.length()),
            sb.getBytes(1, (int) sb.length())));
}
项目:jdk8u-jdk    文件:SerialBlobTests.java   
@Test
public void test11() throws Exception {
    byte[] expected = new byte[]{1, 2, 3};
    SerialBlob sb = new SerialBlob(bytes);
    InputStream is = sb.getBinaryStream(1, 3);
    for (byte b : expected) {
        byte val = (byte) is.read();
        assertTrue(b == val, val + " does not match " + b);
    }
}
项目:jdk8u-jdk    文件:SerialBlobTests.java   
@Test
public void test18() throws Exception {
    SerialBlob sb = new SerialBlob(bytes);
    SerialBlob sb2 = (SerialBlob) sb.clone();
    assertTrue(
            Arrays.equals(sb.getBytes(1, (int) sb.length()),
                    sb2.getBytes(1, (int) sb2.length())),
            "arrays do not match ");
}
项目:jdk8u-jdk    文件:SerialBlobTests.java   
@Test(expectedExceptions = SerialException.class)
public void test19() throws Exception {
    SerialBlob sb = new SerialBlob(bytes);
    sb.free();
    SerialBlob sb2 = (SerialBlob) sb.clone();
    InputStream is = sb2.getBinaryStream(1, 3);
}
项目:jdk8u-jdk    文件:SerialBlobTests.java   
@Test
public void test22() throws Exception {
    byte[] diff = new byte[]{7, 8, 9};
    byte[] expected = new byte[]{1, 7, 8, 9, 5};
    SerialBlob sb = new SerialBlob(bytes);
    int written = sb.setBytes(2, diff);
    assertEquals(written, diff.length);
    assertTrue(
            Arrays.equals(sb.getBytes(1, (int) sb.length()),
                    expected),
            "arrays do not match ");
}
项目:jdk8u-jdk    文件:SerialBlobTests.java   
@Test
public void test23() throws Exception {
    int bytesToWrite = 3;
    byte[] diff = new byte[]{7, 8, 9, 0};
    byte[] expected = new byte[]{1, 8, 9, 0, 5};
    SerialBlob sb = new SerialBlob(bytes);
    int written = sb.setBytes(2, diff, 1, bytesToWrite);
    assertEquals(written, bytesToWrite);
    assertTrue(
            Arrays.equals(sb.getBytes(1, (int) sb.length()),
                    expected),
            "arrays do not match ");
}
项目:jdk8u-jdk    文件:SerialBlobTests.java   
@Test
public void test25() throws Exception {
    byte[] expected = bytes;
    SerialBlob sb = new SerialBlob(bytes);
    InputStream is = sb.getBinaryStream();
    for (byte b : expected) {
        byte val = (byte) is.read();
        assertTrue(b == val, val + " does not match " + b);
    }
}
项目:jdk8u-jdk    文件:SerialBlobTests.java   
@Test
public void test27() throws Exception {
    long expectedPos = 3; // starting offset is 1 vs 0
    byte[] pattern = new byte[]{3, 4};
    SerialBlob sb = new SerialBlob(bytes);
    long pos = sb.position(pattern, 1);
    assertEquals(pos, expectedPos);
}
项目:jdk8u-jdk    文件:SerialBlobTests.java   
@Test
public void test28() throws Exception {
    long expectedPos = 3; // starting offset is 1 vs 0
    byte[] pattern = new byte[]{3, 4, 5};
    SerialBlob sb = new SerialBlob(bytes);
    long pos = sb.position(pattern, 2);
    assertEquals(pos, expectedPos);
}
项目:jdk8u-jdk    文件:SerialBlobTests.java   
@Test
public void test29() throws Exception {
    long expectedPos = 2; // starting offset is 1 vs 0
    byte[] pattern = new byte[]{4, 6};
    SerialBlob sb = new SerialBlob(new StubBlob());
    long pos = sb.position(pattern, 1);
    assertEquals(pos, expectedPos);
}
项目:jdk8u-jdk    文件:SetBinaryStream.java   
public static void main(String[] args) throws Exception {
    SerialBlob blob = new SerialBlob(new byte[0]);
    try {
        blob.setBinaryStream(0);
    } catch (SerialException e) {
        System.out.println("Test PASSED");
    }
}
项目:openjdk-jdk10    文件:BaseRowSetTests.java   
@DataProvider(name = "testAdvancedParameters")
private Object[][] testAdvancedParameters() throws SQLException {

    byte[] bytes = new byte[10];
    Ref aRef = new SerialRef(new StubRef("INTEGER", query));
    Array aArray = new SerialArray(new StubArray("INTEGER", new Object[1]));
    Blob aBlob = new SerialBlob(new StubBlob());
    Clob aClob = new SerialClob(new StubClob());
    Reader rdr = new StringReader(query);
    InputStream is = new StringBufferInputStream(query);;
    brs = new StubBaseRowSet();
    brs.setBytes(1, bytes);
    brs.setAsciiStream(2, is, query.length());
    brs.setRef(3, aRef);
    brs.setArray(4, aArray);
    brs.setBlob(5, aBlob);
    brs.setClob(6, aClob);
    brs.setBinaryStream(7, is, query.length());
    brs.setUnicodeStream(8, is, query.length());
    brs.setCharacterStream(9, rdr, query.length());

    return new Object[][]{
        {1, bytes},
        {2, is},
        {3, aRef},
        {4, aArray},
        {5, aBlob},
        {6, aClob},
        {7, is},
        {8, is},
        {9, rdr}
    };
}
项目:openjdk-jdk10    文件:SQLOutputImplTests.java   
@Test(enabled = true)
public void test05() throws Exception {
    Blob b = new StubBlob();
    outImpl.writeBlob(b);
    SerialBlob sb = (SerialBlob) results.get(0);
    assertTrue(Arrays.equals(
            b.getBytes(1, (int) b.length()),
            sb.getBytes(1, (int) sb.length())));
}
项目:openjdk-jdk10    文件:SerialBlobTests.java   
@Test
public void test11() throws Exception {
    byte[] expected = new byte[]{1, 2, 3};
    SerialBlob sb = new SerialBlob(bytes);
    InputStream is = sb.getBinaryStream(1, 3);
    for (byte b : expected) {
        byte val = (byte) is.read();
        assertTrue(b == val, val + " does not match " + b);
    }
}
项目:openjdk-jdk10    文件:SerialBlobTests.java   
@Test
public void test18() throws Exception {
    SerialBlob sb = new SerialBlob(bytes);
    SerialBlob sb2 = (SerialBlob) sb.clone();
    assertTrue(
            Arrays.equals(sb.getBytes(1, (int) sb.length()),
                    sb2.getBytes(1, (int) sb2.length())),
            "arrays do not match ");
}
项目:openjdk-jdk10    文件:SerialBlobTests.java   
@Test(expectedExceptions = SerialException.class)
public void test19() throws Exception {
    SerialBlob sb = new SerialBlob(bytes);
    sb.free();
    SerialBlob sb2 = (SerialBlob) sb.clone();
    InputStream is = sb2.getBinaryStream(1, 3);
}
项目:openjdk-jdk10    文件:SerialBlobTests.java   
@Test
public void test22() throws Exception {
    byte[] diff = new byte[]{7, 8, 9};
    byte[] expected = new byte[]{1, 7, 8, 9, 5};
    SerialBlob sb = new SerialBlob(bytes);
    int written = sb.setBytes(2, diff);
    assertEquals(written, diff.length);
    assertTrue(
            Arrays.equals(sb.getBytes(1, (int) sb.length()),
                    expected),
            "arrays do not match ");
}
项目:openjdk-jdk10    文件:SerialBlobTests.java   
@Test
public void test23() throws Exception {
    int bytesToWrite = 3;
    byte[] diff = new byte[]{7, 8, 9, 0};
    byte[] expected = new byte[]{1, 8, 9, 0, 5};
    SerialBlob sb = new SerialBlob(bytes);
    int written = sb.setBytes(2, diff, 1, bytesToWrite);
    assertEquals(written, bytesToWrite);
    assertTrue(
            Arrays.equals(sb.getBytes(1, (int) sb.length()),
                    expected),
            "arrays do not match ");
}
项目:openjdk-jdk10    文件:SerialBlobTests.java   
@Test
public void test25() throws Exception {
    byte[] expected = bytes;
    SerialBlob sb = new SerialBlob(bytes);
    InputStream is = sb.getBinaryStream();
    for (byte b : expected) {
        byte val = (byte) is.read();
        assertTrue(b == val, val + " does not match " + b);
    }
}
项目:openjdk-jdk10    文件:SerialBlobTests.java   
@Test
public void test27() throws Exception {
    long expectedPos = 3; // starting offset is 1 vs 0
    byte[] pattern = new byte[]{3, 4};
    SerialBlob sb = new SerialBlob(bytes);
    long pos = sb.position(pattern, 1);
    assertEquals(pos, expectedPos);
}
项目:openjdk-jdk10    文件:SerialBlobTests.java   
@Test
public void test28() throws Exception {
    long expectedPos = 3; // starting offset is 1 vs 0
    byte[] pattern = new byte[]{3, 4, 5};
    SerialBlob sb = new SerialBlob(bytes);
    long pos = sb.position(pattern, 2);
    assertEquals(pos, expectedPos);
}
项目:openjdk-jdk10    文件:SerialBlobTests.java   
@Test
public void test29() throws Exception {
    long expectedPos = 2; // starting offset is 1 vs 0
    byte[] pattern = new byte[]{4, 6};
    SerialBlob sb = new SerialBlob(new StubBlob());
    long pos = sb.position(pattern, 1);
    assertEquals(pos, expectedPos);
}
项目:openjdk-jdk10    文件:SerialBlobTests.java   
@Test
public void test30() throws Exception {
    long expectedPos = 3; // starting offset is 1 vs 0
    byte[] pattern = new byte[]{6, 8};
    SerialBlob sb = new SerialBlob(new StubBlob());
    long pos = sb.position(pattern, 2);
    assertEquals(pos, expectedPos);
}
项目:openjdk-jdk10    文件:SetBinaryStream.java   
public static void main(String[] args) throws Exception {
    SerialBlob blob = new SerialBlob(new byte[0]);
    try {
        blob.setBinaryStream(0);
    } catch (SerialException e) {
        System.out.println("Test PASSED");
    }
}
项目:openjdk9    文件:BaseRowSetTests.java   
@DataProvider(name = "testAdvancedParameters")
private Object[][] testAdvancedParameters() throws SQLException {

    byte[] bytes = new byte[10];
    Ref aRef = new SerialRef(new StubRef("INTEGER", query));
    Array aArray = new SerialArray(new StubArray("INTEGER", new Object[1]));
    Blob aBlob = new SerialBlob(new StubBlob());
    Clob aClob = new SerialClob(new StubClob());
    Reader rdr = new StringReader(query);
    InputStream is = new StringBufferInputStream(query);;
    brs = new StubBaseRowSet();
    brs.setBytes(1, bytes);
    brs.setAsciiStream(2, is, query.length());
    brs.setRef(3, aRef);
    brs.setArray(4, aArray);
    brs.setBlob(5, aBlob);
    brs.setClob(6, aClob);
    brs.setBinaryStream(7, is, query.length());
    brs.setUnicodeStream(8, is, query.length());
    brs.setCharacterStream(9, rdr, query.length());

    return new Object[][]{
        {1, bytes},
        {2, is},
        {3, aRef},
        {4, aArray},
        {5, aBlob},
        {6, aClob},
        {7, is},
        {8, is},
        {9, rdr}
    };
}
项目:openjdk9    文件:SQLOutputImplTests.java   
@Test(enabled = true)
public void test05() throws Exception {
    Blob b = new StubBlob();
    outImpl.writeBlob(b);
    SerialBlob sb = (SerialBlob) results.get(0);
    assertTrue(Arrays.equals(
            b.getBytes(1, (int) b.length()),
            sb.getBytes(1, (int) sb.length())));
}