Examples of BSONCallback


Examples of org.bson.BSONCallback

        DBObject answer = null;
        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) {
            LOG.warn("String -> DBObject conversion selected, but the following exception occurred. Returning null.", e);
View Full Code Here

Examples of org.bson.BSONCallback

        DBObject answer = null;
        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) {
            LOG.warn("String -> DBObject conversion selected, but the following exception occurred. Returning null.", e);
View Full Code Here

Examples of org.bson.BSONCallback

        DBObject answer = null;
        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) {
            LOG.warn("String -> DBObject conversion selected, but the following exception occurred. Returning null.", e);
View Full Code Here

Examples of org.bson.BSONCallback

        DBObject answer = null;
        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) {
            LOG.warn("String -> DBObject conversion selected, but the following exception occurred. Returning null.", e);
View Full Code Here

Examples of org.bson.BSONCallback

        out.write(buf);
    }

    @Override
    public void readFields(final DataInput in) throws IOException {
        BSONCallback cb = new BasicBSONCallback();
        BSONObject spec;
        byte[] l = new byte[4];
        in.readFully(l);
        int dataLen = org.bson.io.Bits.readInt(l);
        byte[] data = new byte[dataLen + 4];
        System.arraycopy(l, 0, data, 0, 4);
        in.readFully(data, 4, dataLen - 4);
        _bsonDecoder.decode(data, cb);
        spec = (BSONObject) cb.get();
        setInputURI(new MongoClientURI((String) spec.get("inputURI")));

        if (spec.get("authURI") != null) {
            setAuthURI(new MongoClientURI((String) spec.get("authURI")));
        } else {
View Full Code Here

Examples of org.bson.BSONCallback

     *
     * @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. */
            // TODO - Figure out how to gracefully mark this as an empty
View Full Code Here

Examples of org.bson.BSONCallback

     *
     * @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) {
            /* If we can't read another length it's not an error, just return quietly. */
 
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.