Package org.mongojack.internal.object

Examples of org.mongojack.internal.object.BsonObjectGenerator$ArrayNode


    DBObject convertToBasicDbObject(T object) throws MongoException {
        if (object == null) {
            return null;
        }
        BsonObjectGenerator generator = new BsonObjectGenerator();
        try {
            objectMapper.writeValue(generator, object);
        } catch (JsonMappingException e) {
            throw new MongoJsonMappingException(e);
        } catch (IOException e) {
            // This shouldn't happen
            throw new MongoException(
                    "Unknown error occurred converting BSON to object", e);
        }
        return generator.getDBObject();
    }
View Full Code Here


            return null;
        }
        if (isEnabled(Feature.USE_STREAM_SERIALIZATION)) {
            return new JacksonDBObject<T>(object, view);
        } else {
            BsonObjectGenerator generator = new BsonObjectGenerator();
            try {
                objectMapper.writerWithView(view).writeValue(generator, object);
            } catch (JsonMappingException e) {
                throw new MongoJsonMappingException(e);
            } catch (IOException e) {
                // This shouldn't happen
                throw new MongoException(
                        "Unknown error occurred converting BSON to object", e);
            }
            return generator.getDBObject();
        }
    }
View Full Code Here

                // We don't know what it is, just find a serializer for it
                serializer = JacksonAccessor.findValueSerializer(
                        serializerProvider, value.getClass());
            }
        }
        BsonObjectGenerator objectGenerator = new BsonObjectGenerator();
        try {
            serializer.serialize(value, objectGenerator, serializerProvider);
        } catch (IOException e) {
            throw new MongoJsonMappingException("Error serializing value "
                    + value + " in DBQuery operation " + op, e);
        }
        return objectGenerator.getValue();
    }
View Full Code Here

            } else {
                return array;
            }
        } else {
            // We don't know what it is, serialise it
            BsonObjectGenerator generator = new BsonObjectGenerator();
            try {
                objectMapper.writeValue(generator, value);
            } catch (JsonMappingException e) {
                throw new MongoJsonMappingException(e);
            } catch (IOException e) {
                throw new RuntimeException(
                        "Somehow got an IOException writing to memory", e);
            }
            return generator.getValue();
        }
    }
View Full Code Here

    }

    private static Object serializeUpdateField(Object value,
            JsonSerializer serializer, SerializerProvider serializerProvider,
            String op, String field) {
        BsonObjectGenerator objectGenerator = new BsonObjectGenerator();
        try {
            serializer.serialize(value, objectGenerator, serializerProvider);
        } catch (IOException e) {
            throw new MongoJsonMappingException(
                    "Error serializing value in DBUpdate operation " + op
                            + " field " + field, e);
        }
        return objectGenerator.getValue();
    }
View Full Code Here

         *            The java object id to convert from
         * @return The converted database id
         */
        @Override
        public D toDbId(K id) {
            BsonObjectGenerator generator = new BsonObjectGenerator();
            try {
                jsonSerializer.serialize(id, generator, null);
            } catch (IOException e) {
                throw new MongoException("Error serializing ID", e);
            }
            return (D) generator.getValue();
        }
View Full Code Here

TOP

Related Classes of org.mongojack.internal.object.BsonObjectGenerator$ArrayNode

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.