当前位置: 首页>>代码示例>>Java>>正文


Java BsonType.DOCUMENT属性代码示例

本文整理汇总了Java中org.bson.BsonType.DOCUMENT属性的典型用法代码示例。如果您正苦于以下问题:Java BsonType.DOCUMENT属性的具体用法?Java BsonType.DOCUMENT怎么用?Java BsonType.DOCUMENT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.bson.BsonType的用法示例。


在下文中一共展示了BsonType.DOCUMENT属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleArrayForBsonReader

private Object handleArrayForBsonReader(BsonReader bsonReader, Field field, BsonMapperConfig bsonMapperConfig) {
    Class<?> fieldType = field.getType();
    ArrayList<Object> arrayList = new ArrayList<Object>();
    bsonReader.readStartArray();
    while (bsonReader.readBsonType() != BsonType.END_OF_DOCUMENT) {
        BsonType currentBsonType = bsonReader.getCurrentBsonType();
        if (currentBsonType == BsonType.NULL) {
            continue;
        }
        if (currentBsonType == BsonType.ARRAY) {
            arrayList.add(decode(bsonReader, field, bsonMapperConfig));
        } else {
            Object javaValue;
            if (currentBsonType == BsonType.DOCUMENT) {
                javaValue = BsonValueConverterRepertory.getBsonDocumentConverter().decode(bsonReader, fieldType.getComponentType(), bsonMapperConfig);
            } else {
                javaValue = BsonValueConverterRepertory.getByteIOConverterByBsonType(currentBsonType).decode(bsonReader);
            }
            arrayList.add(javaValue);
        }
    }
    bsonReader.readEndArray();
    return arrayList.toArray((Object[]) Array.newInstance(fieldType.getComponentType(), 0));
}
 
开发者ID:welkinbai,项目名称:BsonMapper,代码行数:24,代码来源:BsonArrayConverter.java

示例2: getBsonType

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;
  }
}
 
开发者ID:vert-x3,项目名称:vertx-mongo-client,代码行数:23,代码来源:AbstractJsonCodec.java

示例3: decode

@Override
default T decode(BsonReader reader, DecoderContext decoderContext) {
    T newInstance;
    if (reader.getCurrentBsonType() == null || reader.getCurrentBsonType() == BsonType.DOCUMENT) {
        reader.readStartDocument();
        newInstance = decodeFields(reader, decoderContext, newInstance());
        reader.readEndDocument();
        return newInstance;
    } else {
        LOGGER.error("Expected to read document but reader is in state {}. Skipping value!", reader.getCurrentBsonType());
        reader.skipValue();
        return null;
    }
}
 
开发者ID:axelspringer,项目名称:polymorphia,代码行数:14,代码来源:PolymorphicCodec.java

示例4: getJavaValueByBinaryReader

private Object getJavaValueByBinaryReader(BsonReader bsonReader, Field field, BsonMapperConfig bsonMapperConfig) {
    BsonType currentBsonType = bsonReader.getCurrentBsonType();
    if (currentBsonType == BsonType.DOCUMENT) {
        return decode(bsonReader, field.getType(), bsonMapperConfig);
    }
    if (currentBsonType == BsonType.ARRAY) {
        return BsonValueConverterRepertory.getBsonArrayConverter().decode(bsonReader, field, bsonMapperConfig);
    }
    if (currentBsonType == BsonType.OBJECT_ID) {
        ObjectId objectId = (ObjectId) BsonValueConverterRepertory.getByteIOConverterByBsonType(currentBsonType).decode(bsonReader);
        return getObjectIdByRealType(field.getType(), objectId);
    }
    return BsonValueConverterRepertory.getByteIOConverterByBsonType(currentBsonType).decode(bsonReader);
}
 
开发者ID:welkinbai,项目名称:BsonMapper,代码行数:14,代码来源:BsonDocumentConverter.java

示例5: handleCollectionForBsonReader

Object handleCollectionForBsonReader(BsonReader bsonReader, Field field, BsonMapperConfig bsonMapperConfig) {
    Class<?> fieldType = field.getType();
    Class<?> implClass = Utils.giveImplClassIfSupport(fieldType);
    if (Utils.isUnableAddCollectionClazz(implClass)) {
        return null;
    }
    BsonArrayField bsonArrayField = Utils.getBsonArrayFieldAnnotation(field);
    Class<?> targetComponentClazz = bsonArrayField.componentType();

    Object collectionObject = Utils.newInstanceByClazz(implClass);
    Method method;
    try {
        method = implClass.getMethod("add", Object.class);
    } catch (NoSuchMethodException e) {
        throw new BsonMapperConverterException("NoSuchMethodException", e);
    }

    bsonReader.readStartArray();
    while (bsonReader.readBsonType() != BsonType.END_OF_DOCUMENT) {
        BsonType currentBsonType = bsonReader.getCurrentBsonType();
        if (currentBsonType == BsonType.NULL) {
            continue;
        }
        if (currentBsonType == BsonType.ARRAY) {
            Utils.methodInvoke(method, collectionObject, decode(bsonReader, field, bsonMapperConfig));
        } else {
            Object javaValue;
            if (currentBsonType == BsonType.DOCUMENT) {
                javaValue = BsonValueConverterRepertory.getBsonDocumentConverter().decode(bsonReader, targetComponentClazz, bsonMapperConfig);
            } else {
                javaValue = BsonValueConverterRepertory.getByteIOConverterByBsonType(currentBsonType).decode(bsonReader);
            }
            Utils.methodInvoke(method, collectionObject, javaValue);
        }
    }
    bsonReader.readEndArray();
    return collectionObject;
}
 
开发者ID:welkinbai,项目名称:BsonMapper,代码行数:38,代码来源:BsonArrayConverter.java

示例6: startReadMap

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<>();
}
 
开发者ID:neowu,项目名称:core-ng-project,代码行数:13,代码来源:BsonReaderWrapper.java

示例7: startReadEntity

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;
}
 
开发者ID:neowu,项目名称:core-ng-project,代码行数:13,代码来源:BsonReaderWrapper.java

示例8: isExtensionFilterPassed

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;
}
 
开发者ID:JaewookByun,项目名称:epcis,代码行数:30,代码来源:MongoQueryService.java

示例9: isCompExtensionFilterPassed

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;
}
 
开发者ID:JaewookByun,项目名称:epcis,代码行数:79,代码来源:MongoQueryService.java


注:本文中的org.bson.BsonType.DOCUMENT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。