Java 8 SerialBlob - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 SerialBlob class.

This code example shows how to use the following methods:length
        assertNull(read.getReference());
    } 
     
    @Test public void testReferencePersistence() throws Exception {
    	String testString = "this is test clob"; //$NON-NLS-1$
        SerialBlob blob = new SerialBlob(testString.getBytes());
         
        BlobType bv = new BlobType(blob);
        bv.setReferenceStreamId(null);
        // now force to serialize 
        BlobType read = UnitTestUtil.helpSerialize(bv);
                 
        assertNull(read.getReferenceStreamId());
         
        assertEquals(testString, new String(read.getBytes(1, (int)blob.length())));
    } 
     
    public void testBlobCompare() throws Exception {
        String testString = "this is test clob"; //$NON-NLS-1$
        SerialBlob blob = new SerialBlob(testString.getBytes());
5
CodeRank
This code example shows how to use the following methods:
    	 
        List<?>[] expected = new List[] {
        		Arrays.asList(json),
        };     
     
        processPreparedStatement(sql, expected, dataManager, new DefaultCapabilitiesFinder(), RealMetadataFactory.example1Cached(), Arrays.asList(new BlobType(new SerialBlob(json.getBytes(Charset.forName("UTF-16BE"))))));
	} 
	 
	@Test public void testJSONArray() throws Exception {
		HardcodedDataManager dataManager = new HardcodedDataManager();
    	String sql = "select jsonArray(1, null, true, {d '2007-01-01'}, jsonParse('{\"name\":123}', true), unescape('\\t\\n?'))"; //$NON-NLS-1$
    	 
        List<?>[] expected = new List[] {
        		Arrays.asList("[1,null,true,\"2007-01-01\",{\"name\":123},\"\\t\\n?\"]"),
        };     
     
        ProcessorPlan plan = helpGetPlan(sql, RealMetadataFactory.example1Cached());
        helpProcess(plan, dataManager, expected);
	} 
	 
5
CodeRank
This code example shows how to use the following methods:
			TeiidProcessingException, SerialException, IOException {
		CommandContext cc = new CommandContext();
		cc.setBufferManager(BufferManagerFactory.getStandaloneBufferManager());
		SQLXML xml = XMLSystemFunctions.jsonToXml(cc, rootName, new SerialClob(json.toCharArray()));
		assertEquals(expected, xml.getString());
		xml = XMLSystemFunctions.jsonToXml(cc, rootName, new SerialBlob(json.getBytes(Charset.forName("UTF-8"))));
		assertEquals(expected, xml.getString());
		xml = XMLSystemFunctions.jsonToXml(cc, rootName, new SerialBlob(json.getBytes(Charset.forName("UTF-32BE"))));
		assertEquals(expected, xml.getString());
	} 
	 
	@Test public void testJsonToXml1() throws Exception {
		String json = "{ \"firstName\": \"John\", \"lastName\": \"Smith\", \"age\": 25, \"address\": { \"streetAddress\": \"21 2nd Street\", \"city\": \"New York\", \"state\": \"NY\", "+
		         "\"postalCode\": \"10021\" }, \"phoneNumber\": [ { \"type\": \"home\", \"number\": \"212 555-1234\" }, { \"type\": \"fax\", \"number\": \"646 555-4567\" } ] }";  
		String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Person xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><firstName>John</firstName><lastName>Smith</lastName><age xsi:type=\"decimal\">25</age><address><streetAddress>21 2nd Street</streetAddress><city>New York</city><state>NY</state><postalCode>10021</postalCode></address><phoneNumber><type>home</type><number>212 555-1234</number></phoneNumber><phoneNumber><type>fax</type><number>646 555-4567</number></phoneNumber></Person>";
		helpTestJson(json, "Person", expected);
	} 
	 
	@Test public void testJsonToXml2() throws Exception {
		String json = "{ \"firstName\": null }"; 
4
CodeRank
This code example shows how to use the following methods:
		}else{ 
			doc.setContentType(contentTypeService.translateContentType("json"));
		} 
 
		try { 
			Blob blob = new SerialBlob(file.getBytes());
			doc.setFile(blob);
 
			List<Document> appDocs = application.getDocuments();
			if (appDocs == null) { 
				appDocs = list(); 
			} 
			appDocs.add(doc); 
			 
			documentDao.saveOrUpdate(doc);
			applicationDao.saveOrUpdate(application);
 
		} catch (SQLException | IOException e) {
			log.warn("Unable to save document - exception occurs.");
			return null; 
4
CodeRank
This code example shows how to use the following methods:
public class SerialBlobFactory implements SerialLocatorFactory<Blob> 
{ 
	@Override 
	public Blob createSerial(Blob blob) throws SQLException 
	{ 
		return new SerialBlob(blob); 
	} 
} 
4
CodeRank
This code example shows how to use the following methods:
public class BlobConverter implements TypeConverter<Blob> {
 
	@Override 
	public Blob fromBytes(byte[] t) {
		try { 
			return new SerialBlob(t);
		} catch (SerialException e) {
			throw new RuntimeException(e);
		} catch (SQLException e) {
			throw new RuntimeException(e);
		} 
	} 
 
	@Override 
	public Class<?>[] getTypes() {
		return new Class[] { Blob.class };
	} 
 
	@Override 
	public byte[] toBytes(Blob t) {
3
CodeRank
See Code Examples for Java 8 SerialBlob Methods: