Examples of BsonFactory


Examples of de.undercouch.bson4jackson.BsonFactory

    private ObjectMapper objectMapper;

    // {{{ setUp
    @Before
    public void setUp() {
        objectMapper = new ObjectMapper(new BsonFactory());
    }
View Full Code Here

Examples of de.undercouch.bson4jackson.BsonFactory

import java.io.OutputStream;

public class MongoBsonFactory extends BsonFactory {

    public static BsonFactory createFactory() {
        BsonFactory factory = new MongoBsonFactory();
        factory.enable(BsonParser.Feature.HONOR_DOCUMENT_LENGTH);
        return factory;
    }
View Full Code Here

Examples of de.undercouch.bson4jackson.BsonFactory

    @Test
    public void importBsonDumpFileIntoCollection() throws Exception {

        InputStream bsonDump = getClass().getClassLoader().getResourceAsStream("1000friends.bson");
        BsonFactory bsonFactory = new BsonFactory();
        //bsonFactory.enable(BsonParser.Feature.HONOR_DOCUMENT_LENGTH); // fails when enabled
        ObjectReader reader = new ObjectMapper(bsonFactory).reader(BasicBSONObject.class);

        MappingIterator<BSONObject> iterator = reader.readValues(bsonDump);
        try {
View Full Code Here

Examples of de.undercouch.bson4jackson.BsonFactory

    BSONEncoder encoder = new BasicBSONEncoder();
    byte[] barr = encoder.encode(bo);
   
    ByteArrayInputStream bais = new ByteArrayInputStream(barr);
   
    ObjectMapper om = new ObjectMapper(new BsonFactory());
    om.registerModule(new BsonModule());
    T r = om.readValue(bais, cls);
    return r;
  }
View Full Code Here

Examples of de.undercouch.bson4jackson.BsonFactory

    Map<String, Object> m = new LinkedHashMap<String, Object>();
    m.put("data", data);
   
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
   
    ObjectMapper om = new ObjectMapper(new BsonFactory());
    om.registerModule(new BsonModule());
    om.writeValue(baos, m);

    byte[] r = baos.toByteArray();
    ByteArrayInputStream bais = new ByteArrayInputStream(r);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.