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


Java BsonDouble类代码示例

本文整理汇总了Java中org.bson.BsonDouble的典型用法代码示例。如果您正苦于以下问题:Java BsonDouble类的具体用法?Java BsonDouble怎么用?Java BsonDouble使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BsonDouble类属于org.bson包,在下文中一共展示了BsonDouble类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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