本文整理汇总了Java中org.bson.BsonDouble类的典型用法代码示例。如果您正苦于以下问题:Java BsonDouble类的具体用法?Java BsonDouble怎么用?Java BsonDouble使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BsonDouble类属于org.bson包,在下文中一共展示了BsonDouble类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getBsonDocument
import org.bson.BsonDouble; //导入依赖的package包/类
public static BsonDocument getBsonDocument() {
BsonDocument bsonObj = new BsonDocument().append("testDouble", new BsonDouble(20.777));
List<BsonDocument> list = new ArrayList<BsonDocument>();
list.add(bsonObj);
list.add(bsonObj);
byte[] bytes = new byte[3];
bytes[0] = 3;
bytes[1] = 2;
bytes[2] = 1;
BsonDocument bsonDocument = new BsonDocument().append("testDouble", new BsonDouble(20.99))
.append("testString", new BsonString("testStringV"))
.append("testArray", new BsonArray(list));
return new BsonDocument().append("testDouble", new BsonDouble(20.99))
.append("testString", new BsonString("testStringV"))
.append("testArray", new BsonArray(list))
.append("bson_test", bsonDocument)
.append("testBinary", new BsonBinary(bytes))
.append("testBsonUndefined", new BsonUndefined())
.append("testObjectId", new BsonObjectId())
.append("testStringObjectId", new BsonObjectId())
.append("testBoolean", new BsonBoolean(true))
.append("testDate", new BsonDateTime(time))
.append("testNull", new BsonNull())
.append("testInt", new BsonInt32(233))
.append("testLong", new BsonInt64(233332));
}
开发者ID:welkinbai,项目名称:BsonMapper,代码行数:27,代码来源:TestUtil.java
示例2: putQuantityList
import org.bson.BsonDouble; //导入依赖的package包/类
public BsonDocument putQuantityList(BsonDocument base, List<QuantityElement> quantityList) {
BsonArray quantityArray = new BsonArray();
for (QuantityElement quantityElement : quantityList) {
BsonDocument bsonQuantityElement = new BsonDocument("epcClass",
new BsonString(quantityElement.getEpcClass()));
if (quantityElement.getQuantity() != null) {
bsonQuantityElement.put("quantity", new BsonDouble(quantityElement.getQuantity()));
}
if (quantityElement.getUom() != null) {
bsonQuantityElement.put("uom", new BsonString(quantityElement.getUom()));
}
quantityArray.add(bsonQuantityElement);
}
base.put("quantityList", quantityArray);
return base;
}
开发者ID:JaewookByun,项目名称:epcis,代码行数:17,代码来源:CaptureUtil.java
示例3: putChildQuantityList
import org.bson.BsonDouble; //导入依赖的package包/类
public BsonDocument putChildQuantityList(BsonDocument base, List<QuantityElement> childQuantityList) {
BsonArray quantityArray = new BsonArray();
for (QuantityElement quantityElement : childQuantityList) {
BsonDocument bsonQuantityElement = new BsonDocument("epcClass",
new BsonString(quantityElement.getEpcClass()));
if (quantityElement.getQuantity() != null) {
bsonQuantityElement.put("quantity", new BsonDouble(quantityElement.getQuantity()));
}
if (quantityElement.getUom() != null) {
bsonQuantityElement.put("uom", new BsonString(quantityElement.getUom()));
}
quantityArray.add(bsonQuantityElement);
}
base.put("childQuantityList", quantityArray);
return base;
}
开发者ID:JaewookByun,项目名称:epcis,代码行数:17,代码来源:CaptureUtil.java
示例4: putInputQuantityList
import org.bson.BsonDouble; //导入依赖的package包/类
public BsonDocument putInputQuantityList(BsonDocument base, List<QuantityElement> inputQuantityList) {
BsonArray quantityArray = new BsonArray();
for (QuantityElement quantityElement : inputQuantityList) {
BsonDocument bsonQuantityElement = new BsonDocument("epcClass",
new BsonString(quantityElement.getEpcClass()));
if (quantityElement.getQuantity() != null) {
bsonQuantityElement.put("quantity", new BsonDouble(quantityElement.getQuantity()));
}
if (quantityElement.getUom() != null) {
bsonQuantityElement.put("uom", new BsonString(quantityElement.getUom()));
}
quantityArray.add(bsonQuantityElement);
}
base.put("inputQuantityList", quantityArray);
return base;
}
开发者ID:JaewookByun,项目名称:epcis,代码行数:17,代码来源:CaptureUtil.java
示例5: putOutputQuantityList
import org.bson.BsonDouble; //导入依赖的package包/类
public BsonDocument putOutputQuantityList(BsonDocument base, List<QuantityElement> outputQuantityList) {
BsonArray quantityArray = new BsonArray();
for (QuantityElement quantityElement : outputQuantityList) {
BsonDocument bsonQuantityElement = new BsonDocument("epcClass",
new BsonString(quantityElement.getEpcClass()));
if (quantityElement.getQuantity() != null) {
bsonQuantityElement.put("quantity", new BsonDouble(quantityElement.getQuantity()));
}
if (quantityElement.getUom() != null) {
bsonQuantityElement.put("uom", new BsonString(quantityElement.getUom()));
}
quantityArray.add(bsonQuantityElement);
}
base.put("outputQuantityList", quantityArray);
return base;
}
开发者ID:JaewookByun,项目名称:epcis,代码行数:17,代码来源:CaptureUtil.java
示例6: getQuantityObjectList
import org.bson.BsonDouble; //导入依赖的package包/类
static BsonArray getQuantityObjectList(List<QuantityElementType> qetList, Integer gcpLength) {
BsonArray quantityList = new BsonArray();
for (int i = 0; i < qetList.size(); i++) {
BsonDocument quantity = new BsonDocument();
QuantityElementType qet = qetList.get(i);
if (qet.getEpcClass() != null)
quantity.put("epcClass", new BsonString(getClassEPC(qet.getEpcClass().toString(), gcpLength)));
if (qet.getQuantity().doubleValue() != 0) {
quantity.put("quantity", new BsonDouble(qet.getQuantity().doubleValue()));
}
if (qet.getUom() != null)
quantity.put("uom", new BsonString(qet.getUom().toString()));
quantityList.add(quantity);
}
return quantityList;
}
开发者ID:JaewookByun,项目名称:epcis,代码行数:17,代码来源:MongoWriterUtil.java
示例7: getBsonGeoPoint
import org.bson.BsonDouble; //导入依赖的package包/类
public static BsonDocument getBsonGeoPoint(String pointString) {
try {
BsonDocument pointDoc = new BsonDocument();
pointDoc.put("type", new BsonString("Point"));
String[] pointArr = pointString.split(",");
if (pointArr.length != 2)
return null;
BsonArray arr = new BsonArray();
arr.add(new BsonDouble(Double.parseDouble(pointArr[0])));
arr.add(new BsonDouble(Double.parseDouble(pointArr[1])));
pointDoc.put("coordinates", arr);
return pointDoc;
} catch (NumberFormatException e) {
e.printStackTrace();
return null;
}
}
开发者ID:JaewookByun,项目名称:epcis,代码行数:19,代码来源:MongoWriterUtil.java
示例8: converseType
import org.bson.BsonDouble; //导入依赖的package包/类
private static BsonValue converseType(String value) {
String[] valArr = value.split("\\^");
if (valArr.length != 2) {
return new BsonString(value);
}
try {
String type = valArr[1];
if (type.equals("int")) {
return new BsonInt32(Integer.parseInt(valArr[0]));
} else if (type.equals("long")) {
return new BsonInt64(Long.parseLong(valArr[0]));
} else if (type.equals("double")) {
return new BsonDouble(Double.parseDouble(valArr[0]));
} else if (type.equals("boolean")) {
return new BsonBoolean(Boolean.parseBoolean(valArr[0]));
} else {
return new BsonString(value);
}
} catch (NumberFormatException e) {
return new BsonString(value);
}
}
开发者ID:JaewookByun,项目名称:epcis,代码行数:23,代码来源:TriggerEngine.java
示例9: converseType
import org.bson.BsonDouble; //导入依赖的package包/类
static BsonValue converseType(String value) {
String[] valArr = value.split("\\^");
if (valArr.length != 2) {
return new BsonString(value);
}
try {
String type = valArr[1];
if (type.equals("int")) {
return new BsonInt32(Integer.parseInt(valArr[0]));
} else if (type.equals("long")) {
return new BsonInt64(Long.parseLong(valArr[0]));
} else if (type.equals("double")) {
return new BsonDouble(Double.parseDouble(valArr[0]));
} else if (type.equals("boolean")) {
return new BsonBoolean(Boolean.parseBoolean(valArr[0]));
} else {
return new BsonString(value);
}
} catch (NumberFormatException e) {
return new BsonString(value);
}
}
开发者ID:JaewookByun,项目名称:epcis,代码行数:23,代码来源:MongoQueryUtil.java
示例10: getQuantityObjectList
import org.bson.BsonDouble; //导入依赖的package包/类
static BsonArray getQuantityObjectList(List<QuantityElementType> qetList, Integer gcpLength) {
BsonArray quantityList = new BsonArray();
for (int i = 0; i < qetList.size(); i++) {
BsonDocument quantity = new BsonDocument();
QuantityElementType qet = qetList.get(i);
if (qet.getEpcClass() != null)
quantity.put("epcClass", new BsonString(getClassEPC(qet.getEpcClass().toString(), gcpLength)));
if (qet.getQuantity() != 0) {
quantity.put("quantity", new BsonDouble(qet.getQuantity()));
}
if (qet.getUom() != null)
quantity.put("uom", new BsonString(qet.getUom().toString()));
quantityList.add(quantity);
}
return quantityList;
}
开发者ID:JaewookByun,项目名称:epcis,代码行数:17,代码来源:MongoWriterUtil.java
示例11: getChronoVertexSet
import org.bson.BsonDouble; //导入依赖的package包/类
/**
* Geospatial query
*
* @param key
* should be indexed by 2dsphere
* db.vertices.createIndex({"urn:oliot:ubv:mda:gps" : "2dsphere"})
* @param lon
* @param lat
* @param radius
* in metres db.vertices.find({ "urn:oliot:ubv:mda:gps" : { $near : {
* $geometry: { type: "Point", coordinates: [ -1.1673,52.93]},
* $maxDistance: 50000}}})
*
* @return
*/
public HashSet<ChronoVertex> getChronoVertexSet(String key, double lon, double lat, double radius) {
HashSet<ChronoVertex> ret = new HashSet<ChronoVertex>();
BsonArray coordinates = new BsonArray();
coordinates.add(new BsonDouble(lon));
coordinates.add(new BsonDouble(lat));
BsonDocument geometry = new BsonDocument();
geometry.put("type", new BsonString("Point"));
geometry.put("coordinates", coordinates);
BsonDocument near = new BsonDocument();
near.put("$geometry", geometry);
near.put("$maxDistance", new BsonDouble(radius));
BsonDocument geoquery = new BsonDocument();
geoquery.put("$near", near);
BsonDocument queryDoc = new BsonDocument();
queryDoc.put(key, geoquery);
MongoCursor<BsonDocument> cursor = vertices.find(queryDoc).projection(Tokens.PRJ_ONLY_ID).iterator();
while (cursor.hasNext()) {
BsonDocument v = cursor.next();
ret.add(new ChronoVertex(v.getString(Tokens.ID).getValue(), this));
}
return ret;
}
开发者ID:JaewookByun,项目名称:epcis,代码行数:41,代码来源:ChronoGraph.java
示例12: getChronoVertexStream
import org.bson.BsonDouble; //导入依赖的package包/类
/**
* Geospatial query
*
* @param key
* should be indexed by 2dsphere
* db.vertices.createIndex({"urn:oliot:ubv:mda:gps" : "2dsphere"})
* @param lon
* @param lat
* @param radius
* in metres db.vertices.find({ "urn:oliot:ubv:mda:gps" : { $near : {
* $geometry: { type: "Point", coordinates: [ -1.1673,52.93]},
* $maxDistance: 50000}}})
*
* @return
*/
public Stream<ChronoVertex> getChronoVertexStream(String key, double lon, double lat, double radius) {
HashSet<ChronoVertex> ret = new HashSet<ChronoVertex>();
BsonArray coordinates = new BsonArray();
coordinates.add(new BsonDouble(lon));
coordinates.add(new BsonDouble(lat));
BsonDocument geometry = new BsonDocument();
geometry.put("type", new BsonString("Point"));
geometry.put("coordinates", coordinates);
BsonDocument near = new BsonDocument();
near.put("$geometry", geometry);
near.put("$maxDistance", new BsonDouble(radius));
BsonDocument geoquery = new BsonDocument();
geoquery.put("$near", near);
BsonDocument queryDoc = new BsonDocument();
queryDoc.put(key, geoquery);
MongoCursor<BsonDocument> cursor = vertices.find(queryDoc).projection(Tokens.PRJ_ONLY_ID).iterator();
while (cursor.hasNext()) {
BsonDocument v = cursor.next();
ret.add(new ChronoVertex(v.getString(Tokens.ID).getValue(), this));
}
return ret.parallelStream();
}
开发者ID:JaewookByun,项目名称:epcis,代码行数:41,代码来源:ChronoGraph.java
示例13: generateHistogram
import org.bson.BsonDouble; //导入依赖的package包/类
private BsonDocument generateHistogram(Histogram histogram) {
BsonDocument document = new BsonDocument();
final Snapshot snapshot = histogram.getSnapshot();
document.append("count", new BsonInt64(histogram.getCount()));
document.append("max", new BsonDouble(snapshot.getMax()));
document.append("mean", new BsonDouble(snapshot.getMean()));
document.append("min", new BsonDouble(snapshot.getMin()));
document.append("p50", new BsonDouble(snapshot.getMedian()));
document.append("p75", new BsonDouble(snapshot.get75thPercentile()));
document.append("p95", new BsonDouble(snapshot.get95thPercentile()));
document.append("p98", new BsonDouble(snapshot.get98thPercentile()));
document.append("p99", new BsonDouble(snapshot.get99thPercentile()));
document.append("p999", new BsonDouble(snapshot.get999thPercentile()));
if (showSamples) {
document.append("values", new BsonArray(
Arrays.stream(snapshot.getValues())
.mapToObj(BsonInt64::new)
.collect(Collectors.toList())
));
}
document.append("stddev", new BsonDouble(snapshot.getStdDev()));
return document;
}
开发者ID:SoftInstigate,项目名称:restheart,代码行数:26,代码来源:MetricsJsonGenerator.java
示例14: testGetUriWithFilterMany
import org.bson.BsonDouble; //导入依赖的package包/类
@Test
public void testGetUriWithFilterMany() {
BsonValue[] ids = new BsonValue[]{
new BsonInt32(1),
new BsonDouble(20.0d),
new BsonString("id")};
RequestContext context = prepareRequestContext();
String expResult = "/dbName/collName?filter={'_id':{'$in':[1,20.0,\'id\']}}";
String result;
try {
result = URLUtils.getUriWithFilterMany(context, "dbName", "collName", ids);
assertEquals(expResult, result);
} catch (UnsupportedDocumentIdException ex) {
fail(ex.getMessage());
}
}
开发者ID:SoftInstigate,项目名称:restheart,代码行数:18,代码来源:URLUtilsTest.java
示例15: testGetUriWithFilterManyString
import org.bson.BsonDouble; //导入依赖的package包/类
@Test
public void testGetUriWithFilterManyString() {
BsonValue[] ids = new BsonValue[]{
new BsonInt32(1),
new BsonDouble(20.0d),
new BsonString("id")};
RequestContext context = prepareRequestContext();
String expResult = "/dbName/collName?filter={'_id':{'$in':[1,20.0,'id']}}";
String result;
try {
result = URLUtils.getUriWithFilterMany(context, "dbName", "collName", ids);
assertEquals(expResult, result);
} catch (UnsupportedDocumentIdException ex) {
fail(ex.getMessage());
}
}
开发者ID:SoftInstigate,项目名称:restheart,代码行数:18,代码来源:URLUtilsTest.java
示例16: bsonToGson
import org.bson.BsonDouble; //导入依赖的package包/类
/**
* Reading from BSON to GSON
*/
@Test
public void bsonToGson() throws Exception {
BsonDocument document = new BsonDocument();
document.append("boolean", new BsonBoolean(true));
document.append("int32", new BsonInt32(32));
document.append("int64", new BsonInt64(64));
document.append("double", new BsonDouble(42.42D));
document.append("string", new BsonString("foo"));
document.append("null", new BsonNull());
document.append("array", new BsonArray());
document.append("object", new BsonDocument());
JsonElement element = TypeAdapters.JSON_ELEMENT.read(new BsonReader(new BsonDocumentReader(document)));
check(element.isJsonObject());
check(element.getAsJsonObject().get("boolean").getAsJsonPrimitive().isBoolean());
check(element.getAsJsonObject().get("boolean").getAsJsonPrimitive().getAsBoolean());
check(element.getAsJsonObject().get("int32").getAsJsonPrimitive().isNumber());
check(element.getAsJsonObject().get("int32").getAsJsonPrimitive().getAsNumber().intValue()).is(32);
check(element.getAsJsonObject().get("int64").getAsJsonPrimitive().isNumber());
check(element.getAsJsonObject().get("int64").getAsJsonPrimitive().getAsNumber().longValue()).is(64L);
check(element.getAsJsonObject().get("double").getAsJsonPrimitive().isNumber());
check(element.getAsJsonObject().get("double").getAsJsonPrimitive().getAsNumber().doubleValue()).is(42.42D);
check(element.getAsJsonObject().get("string").getAsJsonPrimitive().isString());
check(element.getAsJsonObject().get("string").getAsJsonPrimitive().getAsString()).is("foo");
check(element.getAsJsonObject().get("null").isJsonNull());
check(element.getAsJsonObject().get("array").isJsonArray());
check(element.getAsJsonObject().get("object").isJsonObject());
}
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:38,代码来源:BsonReaderTest.java
示例17: getDouble
import org.bson.BsonDouble; //导入依赖的package包/类
@Override
public Double getDouble(Object key) {
BsonDouble aDouble = innerBsonDocument.getDouble(key);
if (aDouble != null) {
return (Double) BsonValueConverterRepertory.getValueConverterByBsonType(aDouble.getBsonType()).decode(aDouble);
} else {
return null;
}
}
开发者ID:welkinbai,项目名称:BsonMapper,代码行数:10,代码来源:TDocument.java
示例18: getBsonDocumentHasDeepLayer
import org.bson.BsonDouble; //导入依赖的package包/类
private BsonDocument getBsonDocumentHasDeepLayer() {
BsonDocument bsonObj = new BsonDocument().append("testDouble", new BsonDouble(20.777));
List<BsonDocument> list = new ArrayList<BsonDocument>();
list.add(bsonObj);
list.add(bsonObj);
BsonDocument deepBsonDocument = new BsonDocument().append("testDouble", new BsonDouble(20.99))
.append("testString", new BsonString("testStringV"))
.append("testArray", new BsonArray(list));
BsonDocument bsonDocument1 = new BsonDocument().append("testDouble", new BsonDouble(20.99))
.append("testString", new BsonString("testStringV"))
.append("bson_test", deepBsonDocument);
BsonDocument bsonDocument2 = new BsonDocument().append("testDouble", new BsonDouble(20.99))
.append("testString", new BsonString("testStringV"))
.append("bson_test", bsonDocument1);
BsonDocument bsonDocument3 = new BsonDocument().append("testDouble", new BsonDouble(20.99))
.append("testString", new BsonString("testStringV"))
.append("bson_test", bsonDocument2)
.append("testArray", new BsonArray(list));
BsonDocument bsonDocument4 = new BsonDocument().append("testDouble", new BsonDouble(20.99))
.append("testString", new BsonString("testStringV"))
.append("bson_test", bsonDocument3)
.append("testArray", new BsonArray(list));
BsonDocument bsonDocument5 = new BsonDocument().append("testDouble", new BsonDouble(20.99))
.append("testString", new BsonString("testStringV"))
.append("bson_test", bsonDocument4)
.append("testArray", new BsonArray(list));
return new BsonDocument().append("testDouble", new BsonDouble(20.99))
.append("bson_test", bsonDocument5)
.append("testLong", new BsonInt64(233332));
}
开发者ID:welkinbai,项目名称:BsonMapper,代码行数:31,代码来源:DefaultBsonMapperTest.java
示例19: testDoubleType
import org.bson.BsonDouble; //导入依赖的package包/类
@Test
public void testDoubleType() throws IOException {
BsonDocument bsonDoc = new BsonDocument();
bsonDoc.append("doubleKey", new BsonDouble(12.35));
writer.reset();
bsonReader.write(writer, new BsonDocumentReader(bsonDoc));
SingleMapReaderImpl mapReader = (SingleMapReaderImpl) writer.getMapVector().getReader();
assertEquals(12.35d, mapReader.reader("doubleKey").readDouble().doubleValue(), 0.00001);
}
开发者ID:axbaretto,项目名称:drill,代码行数:10,代码来源:TestBsonRecordReader.java
示例20: converseType
import org.bson.BsonDouble; //导入依赖的package包/类
public static BsonValue converseType(String value) {
String[] valArr = value.split("\\^");
if (valArr.length != 2) {
return new BsonString(value);
}
try {
String type = valArr[1];
if (type.equals("int")) {
return new BsonInt32(Integer.parseInt(valArr[0]));
} else if (type.equals("long")) {
return new BsonInt64(Long.parseLong(valArr[0]));
} else if (type.equals("double")) {
return new BsonDouble(Double.parseDouble(valArr[0]));
} else if (type.equals("boolean")) {
return new BsonBoolean(Boolean.parseBoolean(valArr[0]));
} else if (type.equals("float")) {
return new BsonDouble(Double.parseDouble(valArr[0]));
} else if (type.equals("dateTime")) {
BsonDateTime time = getBsonDateTime(valArr[0]);
if (time != null)
return time;
return new BsonString(value);
} else if (type.equals("geoPoint")) {
BsonDocument point = getBsonGeoPoint(valArr[0]);
if (point == null)
return new BsonString(value);
return point;
} else if (type.equals("geoArea")) {
BsonDocument area = getBsonGeoArea(valArr[0]);
if (area == null)
return new BsonString(value);
return area;
} else {
return new BsonString(value);
}
} catch (NumberFormatException e) {
return new BsonString(value);
}
}
开发者ID:JaewookByun,项目名称:epcis,代码行数:40,代码来源:MongoWriterUtil.java
注:本文中的org.bson.BsonDouble类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论