Java Code Examples for org.bson.BsonType#DOCUMENT
The following examples show how to use
org.bson.BsonType#DOCUMENT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractJsonCodec.java From vertx-mongo-client with Apache License 2.0 | 6 votes |
protected BsonType getBsonType(Object value) { if (value == null) { return BsonType.NULL; } else if (value instanceof Boolean) { return BsonType.BOOLEAN; } else if (value instanceof Double) { return BsonType.DOUBLE; } else if (value instanceof Integer) { return BsonType.INT32; } else if (value instanceof Long) { return BsonType.INT64; } else if (value instanceof String) { return BsonType.STRING; } else if (isObjectIdInstance(value)) { return BsonType.OBJECT_ID; } else if (isObjectInstance(value)) { return BsonType.DOCUMENT; } else if (isArrayInstance(value)) { return BsonType.ARRAY; } else { return null; } }
Example 2
Source File: BsonReaderWrapper.java From core-ng-project with Apache License 2.0 | 5 votes |
public Map<String, ?> startReadMap(String field) { BsonType currentType = reader.getCurrentBsonType(); if (currentType == BsonType.NULL) { reader.readNull(); return null; } if (currentType != BsonType.DOCUMENT) { logger.warn("unexpected field type, field={}, type={}", field, currentType); reader.skipValue(); return null; } return new LinkedHashMap<>(); }
Example 3
Source File: BsonReaderWrapper.java From core-ng-project with Apache License 2.0 | 5 votes |
public boolean startReadEntity(String field) { BsonType currentType = reader.getCurrentBsonType(); if (currentType != null && currentType == BsonType.NULL) { reader.readNull(); return false; } if (currentType != null && currentType != BsonType.DOCUMENT) { logger.warn("unexpected field type, field={}, type={}", field, currentType); reader.skipValue(); return false; } return true; }
Example 4
Source File: MongoQueryService.java From epcis with Apache License 2.0 | 5 votes |
private boolean isExtensionFilterPassed(String type, BsonArray paramArray, BsonDocument ext, boolean isTopLevel) { type = MongoWriterUtil.encodeMongoObjectKey(type); Iterator<String> keyIterator = ext.keySet().iterator(); while (keyIterator.hasNext()) { String key = keyIterator.next(); BsonValue sub = ext.get(key); if (isTopLevel == false) { if (key.equals(type)) { for (int i = 0; i < paramArray.size(); i++) { BsonValue param = paramArray.get(i); if (sub.getBsonType() == param.getBsonType() && sub.toString().equals(param.toString())) { return true; } if (param.getBsonType() == BsonType.REGULAR_EXPRESSION && sub.getBsonType() == BsonType.STRING) { if (Pattern.matches(param.asRegularExpression().getPattern(), sub.asString().getValue())) return true; } } return false; } } if (sub.getBsonType() == BsonType.DOCUMENT) { if (isExtensionFilterPassed(type, paramArray, sub.asDocument(), false) == true) { return true; } } } return false; }
Example 5
Source File: MongoQueryService.java From epcis with Apache License 2.0 | 5 votes |
private boolean isExtensionFilterPassed(String type, BsonArray paramArray, BsonDocument ext, boolean isTopLevel) { type = MongoWriterUtil.encodeMongoObjectKey(type); Iterator<String> keyIterator = ext.keySet().iterator(); while (keyIterator.hasNext()) { String key = keyIterator.next(); BsonValue sub = ext.get(key); if (isTopLevel == false) { if (key.equals(type)) { for (int i = 0; i < paramArray.size(); i++) { BsonValue param = paramArray.get(i); if (sub.getBsonType() == param.getBsonType() && sub.toString().equals(param.toString())) { return true; } if (param.getBsonType() == BsonType.REGULAR_EXPRESSION && sub.getBsonType() == BsonType.STRING) { if (Pattern.matches(param.asRegularExpression().getPattern(), sub.asString().getValue())) return true; } } return false; } } if (sub.getBsonType() == BsonType.DOCUMENT) { if (isExtensionFilterPassed(type, paramArray, sub.asDocument(), false) == true) { return true; } } } return false; }
Example 6
Source File: ObjectCodec.java From morphia with Apache License 2.0 | 5 votes |
@Override public Object decode(final BsonReader reader, final DecoderContext decoderContext) { BsonType bsonType = reader.getCurrentBsonType(); Class<?> clazz; if (bsonType == BsonType.DOCUMENT) { clazz = Document.class; String discriminatorField = mapper.getOptions().getDiscriminatorKey(); BsonReaderMark mark = reader.getMark(); reader.readStartDocument(); while (clazz.equals(Document.class) && reader.readBsonType() != BsonType.END_OF_DOCUMENT) { if (reader.readName().equals(discriminatorField)) { try { clazz = mapper.getClass(reader.readString()); } catch (CodecConfigurationException e) { throw new MappingException(e.getMessage(), e); } } else { reader.skipValue(); } } mark.reset(); } else { clazz = bsonTypeClassMap.get(bsonType); } return mapper.getCodecRegistry() .get(clazz) .decode(reader, decoderContext); }
Example 7
Source File: MongoQueryService.java From epcis with Apache License 2.0 | 4 votes |
private boolean isCompExtensionFilterPassed(String type, String comp, BsonArray paramArray, BsonDocument ext) { type = MongoWriterUtil.encodeMongoObjectKey(type); Iterator<String> keyIterator = ext.keySet().iterator(); while (keyIterator.hasNext()) { String key = keyIterator.next(); BsonValue sub = ext.get(key); if (key.equals(type)) { for (int i = 0; i < paramArray.size(); i++) { BsonValue param = paramArray.get(i); if (sub.getBsonType() == param.getBsonType()) { if (sub.getBsonType() == BsonType.INT32) { if (comp.equals("GT")) { if (sub.asInt32().getValue() > param.asInt32().getValue()) return true; } else if (comp.equals("GE")) { if (sub.asInt32().getValue() >= param.asInt32().getValue()) return true; } else if (comp.equals("LT")) { if (sub.asInt32().getValue() < param.asInt32().getValue()) return true; } else if (comp.equals("LE")) { if (sub.asInt32().getValue() <= param.asInt32().getValue()) return true; } } else if (sub.getBsonType() == BsonType.INT64) { if (comp.equals("GT")) { if (sub.asInt64().getValue() > param.asInt64().getValue()) return true; } else if (comp.equals("GE")) { if (sub.asInt64().getValue() >= param.asInt64().getValue()) return true; } else if (comp.equals("LT")) { if (sub.asInt64().getValue() < param.asInt64().getValue()) return true; } else if (comp.equals("LE")) { if (sub.asInt64().getValue() <= param.asInt64().getValue()) return true; } } else if (sub.getBsonType() == BsonType.DOUBLE) { if (comp.equals("GT")) { if (sub.asDouble().getValue() > param.asDouble().getValue()) return true; } else if (comp.equals("GE")) { if (sub.asDouble().getValue() >= param.asDouble().getValue()) return true; } else if (comp.equals("LT")) { if (sub.asDouble().getValue() < param.asDouble().getValue()) return true; } else if (comp.equals("LE")) { if (sub.asDouble().getValue() <= param.asDouble().getValue()) return true; } } else if (sub.getBsonType() == BsonType.DATE_TIME) { if (comp.equals("GT")) { if (sub.asDateTime().getValue() > param.asDateTime().getValue()) return true; } else if (comp.equals("GE")) { if (sub.asDateTime().getValue() >= param.asDateTime().getValue()) return true; } else if (comp.equals("LT")) { if (sub.asDateTime().getValue() < param.asDateTime().getValue()) return true; } else if (comp.equals("LE")) { if (sub.asDateTime().getValue() <= param.asDateTime().getValue()) return true; } } } } return false; } if (sub.getBsonType() == BsonType.DOCUMENT) { if (isCompExtensionFilterPassed(type, comp, paramArray, sub.asDocument()) == true) { return true; } } } return false; }
Example 8
Source File: MongoQueryService.java From epcis with Apache License 2.0 | 4 votes |
private boolean isCompExtensionFilterPassed(String type, String comp, BsonArray paramArray, BsonDocument ext) { type = MongoWriterUtil.encodeMongoObjectKey(type); Iterator<String> keyIterator = ext.keySet().iterator(); while (keyIterator.hasNext()) { String key = keyIterator.next(); BsonValue sub = ext.get(key); if (key.equals(type)) { for (int i = 0; i < paramArray.size(); i++) { BsonValue param = paramArray.get(i); if (sub.getBsonType() == param.getBsonType()) { if (sub.getBsonType() == BsonType.INT32) { if (comp.equals("GT")) { if (sub.asInt32().getValue() > param.asInt32().getValue()) return true; } else if (comp.equals("GE")) { if (sub.asInt32().getValue() >= param.asInt32().getValue()) return true; } else if (comp.equals("LT")) { if (sub.asInt32().getValue() < param.asInt32().getValue()) return true; } else if (comp.equals("LE")) { if (sub.asInt32().getValue() <= param.asInt32().getValue()) return true; } } else if (sub.getBsonType() == BsonType.INT64) { if (comp.equals("GT")) { if (sub.asInt64().getValue() > param.asInt64().getValue()) return true; } else if (comp.equals("GE")) { if (sub.asInt64().getValue() >= param.asInt64().getValue()) return true; } else if (comp.equals("LT")) { if (sub.asInt64().getValue() < param.asInt64().getValue()) return true; } else if (comp.equals("LE")) { if (sub.asInt64().getValue() <= param.asInt64().getValue()) return true; } } else if (sub.getBsonType() == BsonType.DOUBLE) { if (comp.equals("GT")) { if (sub.asDouble().getValue() > param.asDouble().getValue()) return true; } else if (comp.equals("GE")) { if (sub.asDouble().getValue() >= param.asDouble().getValue()) return true; } else if (comp.equals("LT")) { if (sub.asDouble().getValue() < param.asDouble().getValue()) return true; } else if (comp.equals("LE")) { if (sub.asDouble().getValue() <= param.asDouble().getValue()) return true; } } else if (sub.getBsonType() == BsonType.DATE_TIME) { if (comp.equals("GT")) { if (sub.asDateTime().getValue() > param.asDateTime().getValue()) return true; } else if (comp.equals("GE")) { if (sub.asDateTime().getValue() >= param.asDateTime().getValue()) return true; } else if (comp.equals("LT")) { if (sub.asDateTime().getValue() < param.asDateTime().getValue()) return true; } else if (comp.equals("LE")) { if (sub.asDateTime().getValue() <= param.asDateTime().getValue()) return true; } } } } return false; } if (sub.getBsonType() == BsonType.DOCUMENT) { if (isCompExtensionFilterPassed(type, comp, paramArray, sub.asDocument()) == true) { return true; } } } return false; }
Example 9
Source File: ReaderState.java From morphia with Apache License 2.0 | 4 votes |
@Override BsonType getCurrentBsonType() { return BsonType.DOCUMENT; }
Example 10
Source File: ReaderState.java From morphia with Apache License 2.0 | 4 votes |
@Override BsonType getCurrentBsonType() { return BsonType.DOCUMENT; }