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


Java BsonType.STRING属性代码示例

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


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

示例1: scalarToString

/**
 * Gson library reads numbers lazily when using generic {@link com.google.gson.internal.bind.TypeAdapters#JSON_ELEMENT} type adapter.
 * Number is read as string and then wrapped inside {@link LazilyParsedNumber}. This inefficiency should only occur if reading numbers with generic JSON element API
 * and not using generated type adapters.
 *
 * @see LazilyParsedNumber
 * @see com.google.gson.internal.bind.TypeAdapters#JSON_ELEMENT
 */
private String scalarToString() throws IOException {
  final BsonType type = delegate.getCurrentBsonType();

  if (type == BsonType.STRING) {
    return delegate.readString();
  } else if (type == BsonType.SYMBOL) {
    return delegate.readSymbol();
  } else if (type == BsonType.INT32) {
    return Integer.toString(nextInt());
  } else if (type == BsonType.INT64) {
    return Long.toString(nextLong());
  } else if (type == BsonType.DOUBLE) {
    return Double.toString(nextDouble());
  }

  throw new IllegalStateException(String.format("Unknown scalar type to be converted to string: %s", type));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:BsonReader.java

示例2: read

public T read(BsonReader reader, String field) {
    BsonType currentType = reader.getCurrentBsonType();
    if (currentType == BsonType.NULL) {
        reader.readNull();
        return null;
    } else if (currentType == BsonType.STRING) {
        String enumValue = reader.readString();
        T value = decodingMappings.get(enumValue);
        if (value == null) throw Exceptions.error("can not decode value to enum, enumClass={}, value={}", enumClass.getCanonicalName(), enumValue);
        return value;
    } else {
        logger.warn("unexpected field type, field={}, type={}", field, currentType);
        reader.skipValue();
        return null;
    }
}
 
开发者ID:neowu,项目名称:core-ng-project,代码行数:16,代码来源:EnumCodec.java

示例3: convertBsonValueToString

private static String convertBsonValueToString(BsonValue bsonValue) {
	BsonType type = bsonValue.getBsonType();
	String value = null;
	if (type == BsonType.STRING) {
		value = bsonValue.asString().getValue();
	} else if (type == BsonType.INT32) {
		value = String.valueOf(bsonValue.asInt32().getValue());
	} else if (type == BsonType.INT64) {
		value = String.valueOf(bsonValue.asInt64().getValue());
	} else if (type == BsonType.DOUBLE) {
		value = String.valueOf(bsonValue.asDouble().getValue());
	} else if (type == BsonType.BOOLEAN) {
		value = String.valueOf(bsonValue.asBoolean().getValue());
	}
	return value;
}
 
开发者ID:JaewookByun,项目名称:epcis,代码行数:16,代码来源:MongoReaderUtil.java

示例4: 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

示例5: decode

@Override
public Integer decode(BsonReader reader, DecoderContext decoderContext) {
	if(reader.getCurrentBsonType() == BsonType.STRING) {
		return Integer.valueOf(reader.readString());
	}
	return super.decode(reader, decoderContext);
}
 
开发者ID:JPDSousa,项目名称:mongo-obj-framework,代码行数:7,代码来源:IntegerCodec.java

示例6: readString

public String readString(String field) {
    BsonType currentType = reader.getCurrentBsonType();
    if (currentType == BsonType.NULL) {
        reader.readNull();
        return null;
    } else if (currentType == BsonType.STRING) {
        return reader.readString();
    } else {
        logger.warn("unexpected field type, field={}, type={}", field, currentType);
        reader.skipValue();
        return null;
    }
}
 
开发者ID:neowu,项目名称:core-ng-project,代码行数:13,代码来源:BsonReaderWrapper.java

示例7: 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


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