Package org.bson

Examples of org.bson.BasicBSONDecoder


        try {
            byte[] input = IOConverter.toBytes(is);
           
            if (isBson(input)) {
                BSONCallback callback = new JSONCallback();
                new BasicBSONDecoder().decode(input, callback);
                answer = (DBObject) callback.get();
            } else {
                answer = (DBObject) JSON.parse(IOConverter.toString(input, exchange));
            }
        } catch (Exception e) {
View Full Code Here


        try {
            byte[] input = IOConverter.toBytes(is);
           
            if (isBson(input)) {
                BSONCallback callback = new JSONCallback();
                new BasicBSONDecoder().decode(input, callback);
                answer = (DBObject) callback.get();
            } else {
                answer = (DBObject) JSON.parse(IOConverter.toString(input, exchange));
            }
        } catch (Exception e) {
View Full Code Here

        try {
            byte[] input = IOConverter.toBytes(is);
           
            if (isBson(input)) {
                BSONCallback callback = new JSONCallback();
                new BasicBSONDecoder().decode(input, callback);
                answer = (DBObject) callback.get();
            } else {
                answer = (DBObject) JSON.parse(IOConverter.toString(input, exchange));
            }
        } catch (Exception e) {
View Full Code Here

            } else {
                if (is == null) {
                    is = new FileInputStream(file);
                }
                callback = new DefaultDBCallback(null);
                decoder = new BasicBSONDecoder();
            }

            if (format == Format.JSON_ARRAY) {
                String line = br.readLine();
                BasicDBList list = (BasicDBList) JSON.parse(line);
View Full Code Here

        try {
            byte[] input = IOConverter.toBytes(is);
           
            if (isBson(input)) {
                BSONCallback callback = new JSONCallback();
                new BasicBSONDecoder().decode(input, callback);
                answer = (DBObject) callback.get();
            } else {
                answer = (DBObject) JSON.parse(IOConverter.toString(input, exchange));
            }
        } catch (Exception e) {
View Full Code Here

                // om.writeValue(stream2, jacksonData);
                // byte[] jacksonBytes = stream2.toByteArray();
                // assertSame(bytes, jacksonBytes, "BSON   ", "Jackson");

                start = System.nanoTime();
                new BasicBSONDecoder().decode(bytes, new BasicBSONCallback());
                long mongoReadTime = System.nanoTime() - start;

                Document fromMongo = reader.read(new ByteArrayInputStream(mongoBytes));
                if (!fromMongo.equals(result)) {
                    System.out.println("from Schematic: " + result);
View Full Code Here

        if (MongoConfigUtil.getLazyBSON(configuration)) {
            callback = new LazyBSONCallback();
            decoder = new LazyBSONDecoder();
        } else {
            callback = new BasicBSONCallback();
            decoder = new BasicBSONDecoder();
        }
    }
View Full Code Here

        if (MongoConfigUtil.getLazyBSON(conf)) {
            callback = new LazyBSONCallback();
            decoder = new LazyBSONDecoder();
        } else {
            callback = new BasicBSONCallback();
            decoder = new BasicBSONDecoder();
        }
    }
View Full Code Here

     * {@inheritDoc}
     *
     * @see Writable#readFields(DataInput)
     */
    public void readFields(final DataInput in) throws IOException {
        BSONDecoder dec = new BasicBSONDecoder();
        BSONCallback cb = new BasicBSONCallback();
        // Read the BSON length from the start of the record
        byte[] l = new byte[4];
        try {
            in.readFully(l);
            int dataLen = Bits.readInt(l);
            byte[] data = new byte[dataLen + 4];
            System.arraycopy(l, 0, data, 0, 4);
            in.readFully(data, 4, dataLen - 4);
            dec.decode(data, cb);
            query = (BasicBSONObject) cb.get();
            in.readFully(l);
            dataLen = Bits.readInt(l);
            data = new byte[dataLen + 4];
            System.arraycopy(l, 0, data, 0, 4);
            in.readFully(data, 4, dataLen - 4);
            dec.decode(data, cb);
            modifiers = (BasicBSONObject) cb.get();
            upsert = in.readBoolean();
            multiUpdate = in.readBoolean();
        } catch (Exception e) {
            /* If we can't read another length it's not an error, just return quietly. */
 
View Full Code Here

     * {@inheritDoc}
     *
     * @see Writable#readFields(DataInput)
     */
    public void readFields(final DataInput in) throws IOException {
        BSONDecoder dec = new BasicBSONDecoder();
        BSONCallback cb = new BasicBSONCallback();
        // Read the BSON length from the start of the record
        byte[] l = new byte[4];
        try {
            in.readFully(l);
            int dataLen = Bits.readInt(l);
            if (LOG.isDebugEnabled()) {
                LOG.debug("*** Expected DataLen: " + dataLen);
            }
            byte[] data = new byte[dataLen + 4];
            System.arraycopy(l, 0, data, 0, 4);
            in.readFully(data, 4, dataLen - 4);
            dec.decode(data, cb);
            doc = (BSONObject) cb.get();
            if (LOG.isTraceEnabled()) {
                LOG.trace("Decoded a BSON Object: " + doc);
            }
        } catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.bson.BasicBSONDecoder

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.