Package org.infinispan.schematic.document

Examples of org.infinispan.schematic.document.Binary$Externalizer


    }

    @Test
    public void shouldRoundTripSimpleBsonObjectWithBinary1() {
        byte[] data = new byte[] {0x16, 0x00, 0x00, 0x00, 0x02, 0x68, 0x65, 0x6c};
        input = new BasicDocument("foo", new Binary(data));
        assertRoundtrip(input);
    }
View Full Code Here


        } finally {
            bos.close();
            is.close();
        }

        input = new BasicDocument("foo", new Binary(bos.toByteArray()));
        assertRoundtrip(input);
    }
View Full Code Here

            value = new org.bson.types.CodeWScope(code.getCode(), createMongoData(code.getScope()));
        } else if (value instanceof Code) {
            Code code = (Code)value;
            value = new org.bson.types.Code(code.getCode());
        } else if (value instanceof Binary) {
            Binary binary = (Binary)value;
            value = new org.bson.types.Binary(binary.getBytes());
        } else if (value instanceof List) {
            List<?> values = (List<?>)value;
            BasicBSONList newValues = new BasicBSONList();
            for (Object v : values) {
                newValues.add(createMongoData(v));
View Full Code Here

    }

    @Test
    public void shouldParseDocumentWithBinary() throws Exception {
        byte[] bytes = new byte[] {0x13, 0x22, 0x53, 0x00};
        Binary obj = new Binary(Bson.BinaryType.MD5, bytes);
        value = parser(writer.write(obj)).parseValue();
        assert obj.equals(value);
    }
View Full Code Here

    }

    @Test
    public void shouldCorrectlyWriteBinaryValue() {
        byte[] data = new byte[] {0x00, 0x01, 0x02, 0x03, 0x04, 0x05};
        @SuppressWarnings( "deprecation" )
        Binary binary = new Binary(Bson.BinaryType.BINARY, data);
        String expected = "{ \"$type\" : 2 , \"$base64\" : \"AAECAwQF\" }";
        String actual = writer.write(binary);
        // print =true;
        assertSame(expected, actual);
    }
View Full Code Here

      return Null.getInstance();
   }

   @Override
   public Binary createBinary(byte type, byte[] data) {
      return new Binary(type, data);
   }
View Full Code Here

    private ContentStream jcrBinaryContent( Document document ) {
        // pickup node properties
        Document props = document.getDocument("properties").getDocument(JcrLexicon.Namespace.URI);

        // extract binary value and content
        Binary value = props.getBinary("data");

        if (value == null) {
            return null;
        }

        byte[] content = value.getBytes();
        String fileName = props.getString("fileName");
        String mimeType = props.getString("mimeType");

        // wrap with input stream
        ByteArrayInputStream bin = new ByteArrayInputStream(content);
View Full Code Here

                                         externalBinaryValue.getSourceName());
        }
        if (value instanceof org.modeshape.jcr.value.BinaryValue) {
            org.modeshape.jcr.value.BinaryValue binary = (org.modeshape.jcr.value.BinaryValue)value;
            if (binary instanceof InMemoryBinaryValue) {
                return new Binary(((InMemoryBinaryValue)binary).getBytes());
            }
            // This is a large value ...
            String sha1 = binary.getHexHash();
            long size = binary.getSize();
            Document ref = Schematic.newDocument(SHA1_FIELD, sha1, LENGTH_FIELD, size);
View Full Code Here

        }
        if (value instanceof Double) {
            return value;
        }
        if (value instanceof Binary) {
            Binary binary = (Binary)value;
            return binaries.create(binary.getBytes());
        }
        if (value instanceof URI) {
            URI uri = (URI)value;
            return uris.create(uri);
        }
View Full Code Here

TOP

Related Classes of org.infinispan.schematic.document.Binary$Externalizer

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.