Package org.bson.types

Examples of org.bson.types.Binary


        variety.getSourceCollection().insert(new BasicDBObject()
            .append("key_string", "Just plain String")
            .append("key_boolean", true)
            .append("key_number", 1)
            .append("key_date", new Date())
            .append("key_binData-generic", new Binary((byte)0x00, new byte[]{1,2,3,4}))
            .append("key_binData-function", new Binary((byte) 0x01, new byte[]{1,2,3,4}))
            .append("key_binData-old", new Binary((byte) 0x02, new byte[]{1,2,3,4}))
            .append("key_binData-UUID", new Binary((byte) 0x03, new byte[]{1,2,3,4}))
            .append("key_binData-MD5", new Binary((byte) 0x05, new byte[]{1,2,3,4}))
            .append("key_binData-user", new Binary((byte) 0x80, new byte[]{1,2,3,4}))
            .append("key_array", new ArrayList<>())
            .append("key_object", new BasicDBObject())
            .append("key_null", null)
        );
    }
View Full Code Here


            .get()
        );
        examples.add(
            new BasicDBObjectBuilder()
                .add("name", "Jim")
                .add("someBinData", new Binary((byte) 0x02, new byte[]{1,2,3,4}))
            .get()
        );

        return examples;
    }
View Full Code Here

        FileInputStream fis = null;
        try {
            String path = ((FileSelectorField) getBoundComponentUnit(Item.inputFile)).getPath();
            fis = new FileInputStream(path);
            byte[] bytes = IOUtils.readFully(fis, -1, true);
            return new Binary((byte)0, bytes);
        } catch (Exception ex) {
            getLogger().log(Level.WARNING, null, ex);
        } finally {
            try {
                fis.close();
View Full Code Here

        if (type.equals("Integer")) {
            val = new Integer(0);
        } else if (type.startsWith("Long")) {
            val = new Long(0);
        } else if (type.equals("Binary")) {
            val = new Binary((byte) 0, new byte[1]);
        } else if (type.startsWith("ObjectId")) {
            val = new ObjectId();
        } else if (type.equals("Boolean")) {
            val = new Boolean(true);
        } else if (type.equals("Code")) {
View Full Code Here

    private static class BinaryDeserializer extends JsonDeserializer<Binary> {
        @Override
        public Binary deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
            Object object = jp.getEmbeddedObject();
            return new Binary((byte[]) object);
        }
View Full Code Here

    private Binary friendId;
    private MongoCollection collection;

    @Before
    public void setUp() throws Exception {
        friendId = new Binary("jongo".getBytes());
        collection = createEmptyCollection("friends");
    }
View Full Code Here


    @Test
    public void testSave() throws Exception {
        BinaryFriend expected = new BinaryFriend();
        Binary expectedId = new Binary("friend2".getBytes());
        expected.setId(expectedId);
        expected.setName("friend2");

        collection.save(expected);
View Full Code Here

    }

    @Test
    public void testInsert() throws Exception {
        BinaryFriend expected = new BinaryFriend();
        Binary expectedId = new Binary("friend2".getBytes());
        expected.setId(expectedId);
        expected.setName("friend2");

        collection.insert("#", expected);
View Full Code Here

    @Test
    public void canMarhsallBinary() throws Exception {

        BinaryFriend doc = new BinaryFriend();
        doc.id = new Binary("abcde".getBytes());

        collection.save(doc);

        assertHasBeenPersistedAs(jsonify("'_id' : { '$binary' : 'YWJjZGU=' , '$type' : 0}"));
        BinaryFriend result = collection.findOne().as(BinaryFriend.class);
View Full Code Here

        @JsonProperty("_id")
        private Binary id;
        private String name;

        public Binary getId() {
            return new Binary(id.getData());
        }
View Full Code Here

TOP

Related Classes of org.bson.types.Binary

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.