• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java BsonBoolean类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getBsonDocument

import org.bson.BsonBoolean; //导入依赖的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: testBsonDocumentDeSerialize

import org.bson.BsonBoolean; //导入依赖的package包/类
@Test
public void testBsonDocumentDeSerialize() {
	BsonDocument document = new BsonDocument().append("a", new BsonString("MongoDB"))
               .append("b", new BsonArray(Arrays.asList(new BsonInt32(1), new BsonInt32(2))))
               .append("c", new BsonBoolean(true))
               .append("d", new BsonDateTime(0));

	String json = oson.useAttribute(false).setValueOnly(true).serialize(document);

	String expected = "{\"a\":\"MongoDB\",\"b\":[1,2],\"c\":true,\"d\":0}";

	assertEquals(expected, json);

	BsonDocument document2 = oson.deserialize(json, BsonDocument.class);

	assertEquals(expected, oson.serialize(document2));
}
 
开发者ID:osonus,项目名称:oson,代码行数:18,代码来源:DocumentTest.java


示例3: converseType

import org.bson.BsonBoolean; //导入依赖的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


示例4: getExistsQueryObject

import org.bson.BsonBoolean; //导入依赖的package包/类
static BsonDocument getExistsQueryObject(String[] fieldArr, String str, BsonBoolean isExist) {
	BsonArray conjQueries = new BsonArray();
	for (String field : fieldArr) {
		BsonDocument query = new BsonDocument();
		if (str != null) {
			str = encodeMongoObjectKey(str);
			query.put(field + "." + str, new BsonDocument("$exists", isExist));
		} else {
			query.put(field, new BsonDocument("$exists", isExist));
		}
		conjQueries.add(query);
	}
	if (conjQueries.size() != 0) {
		BsonDocument queryObject = new BsonDocument();
		if (isExist.equals(BsonBoolean.TRUE))
			queryObject.put("$or", conjQueries);
		else {
			queryObject.put("$and", conjQueries);
		}
		return queryObject;
	} else {
		return null;
	}
}
 
开发者ID:JaewookByun,项目名称:epcis,代码行数:25,代码来源:MongoQueryUtil.java


示例5: asBsonDocument

import org.bson.BsonBoolean; //导入依赖的package包/类
public static BsonDocument asBsonDocument(SubscriptionType subscription) {

		BsonDocument bson = new BsonDocument();

		if (subscription.getSubscriptionID() != null) {
			bson.put("subscriptionID", new BsonString(subscription.getSubscriptionID()));
		}
		if (subscription.getDest() != null) {
			bson.put("dest", new BsonString(subscription.getDest()));
		}
		if (subscription.getSchedule() != null) {
			bson.put("schedule", new BsonString(subscription.getSchedule()));
		}
		if (subscription.getTrigger() != null) {
			bson.put("trigger", new BsonString(subscription.getTrigger()));
		}
		if (subscription.getInitialRecordTime() != null) {
			bson.put("initialRecordTime", new BsonString(subscription.getInitialRecordTime()));
		}
		bson.put("reportIfEmpty", new BsonBoolean(subscription.getReportIfEmpty()));
		bson.put("pollParameters", PollParameters.asBsonDocument(subscription.getPollParameters()));
		return bson;
	}
 
开发者ID:JaewookByun,项目名称:epcis,代码行数:24,代码来源:SubscriptionType.java


示例6: converseType

import org.bson.BsonBoolean; //导入依赖的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


示例7: getTimestampProperties

import org.bson.BsonBoolean; //导入依赖的package包/类
/**
 * @param timestamp
 * @param projection
 * @return TimestampProperties BsonDocument only containing projection keys
 */
public BsonDocument getTimestampProperties(final Long timestamp, final String[] projection) {
	BsonDocument bsonProjection = new BsonDocument();
	if (projection != null) {
		for (String string : projection) {
			bsonProjection.append(string, new BsonBoolean(true));
		}
	}

	if (this instanceof ChronoVertex)
		return graph.getVertexEvents()
				.find(new BsonDocument(Tokens.VERTEX, new BsonString(this.id)).append(Tokens.TIMESTAMP, new BsonDateTime(timestamp)))
				.projection(bsonProjection).first();
	else
		return graph.getEdgeCollection()
				.find(new BsonDocument(Tokens.ID, new BsonString(this.id + "-" + timestamp)))
				.projection(bsonProjection).first();
}
 
开发者ID:JaewookByun,项目名称:epcis,代码行数:23,代码来源:ChronoElement.java


示例8: deserialise_boolean

import org.bson.BsonBoolean; //导入依赖的package包/类
@Test public void
deserialise_boolean() {
    Key<Boolean> booleanKey = Key.named("my-value");

    BsonRecordDeserialiser deserialiser = BsonRecordDeserialiser.builder()
            .readBoolean(booleanKey)
            .get();

    BsonDocument trueDoc = new BsonDocument();
    trueDoc.put("my-value", new BsonBoolean(true));
    Record trueRecord = deserialiser.apply(trueDoc);
    assertTrue("wasn't true", booleanKey.get(trueRecord).get());

    BsonDocument falseDoc = new BsonDocument();
    falseDoc.put("my-value", new BsonBoolean(false));
    Record falseRecord = Record.of(booleanKey.of(false));
    assertFalse("wasn't false", booleanKey.get(falseRecord).get());
}
 
开发者ID:poetix,项目名称:octarine,代码行数:19,代码来源:DeserialisationTest.java


示例9: bsonToGson

import org.bson.BsonBoolean; //导入依赖的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


示例10: getBooleanFromInner

import org.bson.BsonBoolean; //导入依赖的package包/类
private Boolean getBooleanFromInner(Object key) {
    BsonBoolean bsonBoolean = innerBsonDocument.getBoolean(key);
    if (bsonBoolean != null) {
        return (Boolean) BsonValueConverterRepertory.getValueConverterByBsonType(bsonBoolean.getBsonType()).decode(bsonBoolean);
    }
    return null;
}
 
开发者ID:welkinbai,项目名称:BsonMapper,代码行数:8,代码来源:TDocument.java


示例11: testBooleanType

import org.bson.BsonBoolean; //导入依赖的package包/类
@Test
public void testBooleanType() throws IOException {
  BsonDocument bsonDoc = new BsonDocument();
  bsonDoc.append("booleanKey", new BsonBoolean(true));
  writer.reset();
  bsonReader.write(writer, new BsonDocumentReader(bsonDoc));
  SingleMapReaderImpl mapReader = (SingleMapReaderImpl) writer.getMapVector().getReader();
  assertTrue(mapReader.reader("booleanKey").readBoolean());
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:10,代码来源:TestBsonRecordReader.java


示例12: converseType

import org.bson.BsonBoolean; //导入依赖的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


示例13: converseType

import org.bson.BsonBoolean; //导入依赖的package包/类
static BsonValue converseType(String value) {
	String[] valArr = value.split("\\^");
	if (valArr.length != 2) {
		return new BsonString(value);
	}
	try {
		String type = valArr[1].trim();
		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("regex")) {
			return new BsonRegularExpression("^" + valArr[0] + "$");
		} else if (type.equals("float")) {
			return new BsonDouble(Double.parseDouble(valArr[0]));
		} else if (type.equals("dateTime")) {
			BsonDateTime time = MongoQueryService.getTimeMillis(valArr[0]);
			if (time != null)
				return time;
			return new BsonString(value);
		} else {
			return new BsonString(value);
		}
	} catch (NumberFormatException e) {
		return new BsonString(value);
	}
}
 
开发者ID:JaewookByun,项目名称:epcis,代码行数:32,代码来源:MongoQueryUtil.java


示例14: getExtensionMap

import org.bson.BsonBoolean; //导入依赖的package包/类
private Map<String, BsonValue> getExtensionMap(List<ECReportMemberField> fields) {
	Map<String, BsonValue> extMap = new HashMap<String, BsonValue>();
	for (int l = 0; l < fields.size(); l++) {
		ECReportMemberField field = fields.get(l);
		String key = field.getName();
		String value = field.getValue();
		String[] valArr = value.split("\\^");
		if (valArr.length != 2) {
			extMap.put(key, new BsonString(value));
			continue;
		}
		try {
			String type = valArr[1];
			if (type.equals("int")) {
				extMap.put(key, new BsonInt32(Integer.parseInt(valArr[0])));
			} else if (type.equals("long")) {
				extMap.put(key, new BsonInt64(Long.parseLong(valArr[0])));
			} else if (type.equals("double")) {
				extMap.put(key, new BsonDouble(Double.parseDouble(valArr[0])));
			} else if (type.equals("boolean")) {
				extMap.put(key, new BsonBoolean(Boolean.parseBoolean(valArr[0])));
			} else if (type.equals("dateTime")) {
				extMap.put(key, new BsonDateTime(Long.parseLong(valArr[0])));
			} else {
				extMap.put(key, new BsonString(valArr[0]));
			}
		} catch (NumberFormatException e) {
			extMap.put(key, new BsonString(valArr[0]));
		}
	}
	return extMap;
}
 
开发者ID:JaewookByun,项目名称:epcis,代码行数:33,代码来源:ECReportCapture.java


示例15: makeOtherwiseIdenticalFilter

import org.bson.BsonBoolean; //导入依赖的package包/类
@SuppressWarnings("unused")
private BsonDocument makeOtherwiseIdenticalFilter(BsonDocument filter) {
	filter.remove("errorDeclaration");
	filter.put("errorDeclaration", new BsonDocument("$exists", new BsonBoolean(false)));
	filter.remove("recordTime");
	return filter;
}
 
开发者ID:JaewookByun,项目名称:epcis,代码行数:8,代码来源:MongoCaptureUtil.java


示例16: getProperty

import org.bson.BsonBoolean; //导入依赖的package包/类
/**
 * Return the object value associated with the provided string key. If no value
 * exists for that key, return null.
 *
 * @param key
 *            the key of the key/value property, Tokens.ID, Tokens.LABEL,
 *            Tokens.OUT_VERTEX, Tokens.IN_VERTEX included
 * @return the object value related to the string key
 */
@Override
public <T> T getProperty(final String key) {
	BsonDocument doc = null;
	if (this instanceof ChronoVertex) {
		doc = graph.getVertexCollection().find(new BsonDocument(Tokens.ID, new BsonString(this.id)))
				.projection(new BsonDocument(key, new BsonBoolean(true))).first();
	} else {
		doc = graph.getEdgeCollection().find(new BsonDocument(Tokens.ID, new BsonString(this.id)))
				.projection(new BsonDocument(key, new BsonBoolean(true))).first();
	}
	if (doc != null)
		return (T) doc.get(key);
	return null;
}
 
开发者ID:JaewookByun,项目名称:epcis,代码行数:24,代码来源:ChronoElement.java


示例17: getOutVertexEventSet

import org.bson.BsonBoolean; //导入依赖的package包/类
public Set<VertexEvent> getOutVertexEventSet(final String label, final AC tt) {

		// db.edges.createIndex({"_outV" : 1, "_label" : 1, "_t" : 1, "_inV" : 1})
		BsonDocument query = new BsonDocument(Tokens.OUT_VERTEX, new BsonString(vertex.toString()));
		query.append(Tokens.LABEL, new BsonString(label));
		query.append(Tokens.TIMESTAMP, new BsonDocument(tt.toString(), new BsonDateTime(timestamp)));
		BsonDocument proj = new BsonDocument(Tokens.TIMESTAMP, new BsonBoolean(true))
				.append(Tokens.IN_VERTEX, new BsonBoolean(true)).append(Tokens.ID, new BsonBoolean(false));

		HashSet<VertexEvent> ret = new HashSet<VertexEvent>();
		Iterator<BsonDocument> x = vertex.graph.getEdgeEvents().find(query).projection(proj).iterator();
		HashMap<String, Long> map = new HashMap<String, Long>();
		while (x.hasNext()) {
			BsonDocument d = x.next();
			String inV = d.getString(Tokens.IN_VERTEX).getValue();
			Long t = d.getDateTime(Tokens.TIMESTAMP).getValue();
			if (map.containsKey(inV)) {
				// TODO:
				if (map.get(inV) > t)
					map.put(inV, t);
			} else
				map.put(inV, t);
		}

		map.entrySet().parallelStream().forEach(entry -> {
			VertexEvent ve = new VertexEvent(graph, entry.getKey() + "-" + entry.getValue());
			ret.add(ve);
		});
		return ret;
	}
 
开发者ID:JaewookByun,项目名称:epcis,代码行数:31,代码来源:VertexEvent.java


示例18: getInVertexEventSet

import org.bson.BsonBoolean; //导入依赖的package包/类
public Set<VertexEvent> getInVertexEventSet(final String label, final AC tt) {

		// db.edges.createIndex({"_outV" : 1, "_label" : 1, "_t" : 1, "_inV" : 1})
		BsonDocument query = new BsonDocument(Tokens.IN_VERTEX, new BsonString(vertex.toString()));
		query.append(Tokens.LABEL, new BsonString(label));
		query.append(Tokens.TIMESTAMP, new BsonDocument(tt.toString(), new BsonDateTime(timestamp)));
		BsonDocument proj = new BsonDocument(Tokens.TIMESTAMP, new BsonBoolean(true))
				.append(Tokens.OUT_VERTEX, new BsonBoolean(true)).append(Tokens.ID, new BsonBoolean(false));

		HashSet<VertexEvent> ret = new HashSet<VertexEvent>();
		Iterator<BsonDocument> x = vertex.graph.getEdgeCollection().find(query).projection(proj).iterator();
		HashMap<String, Long> map = new HashMap<String, Long>();
		while (x.hasNext()) {
			BsonDocument d = x.next();
			String outV = d.getString(Tokens.OUT_VERTEX).getValue();
			Long t = d.getDateTime(Tokens.TIMESTAMP).getValue();
			if (map.containsKey(outV)) {
				// TODO:
				if (map.get(outV) > t)
					map.put(outV, t);
			} else
				map.put(outV, t);
		}

		map.entrySet().parallelStream().forEach(entry -> {
			VertexEvent ve = new VertexEvent(graph, entry.getKey() + "-" + entry.getValue());
			ret.add(ve);
		});
		return ret;
	}
 
开发者ID:JaewookByun,项目名称:epcis,代码行数:31,代码来源:VertexEvent.java


示例19: getIdAsBoolean

import org.bson.BsonBoolean; //导入依赖的package包/类
private static BsonBoolean getIdAsBoolean(String id) throws IllegalArgumentException {
    if (id.equals(RequestContext.TRUE_KEY_ID)) {
        return new BsonBoolean(true);
    }

    if (id.equals(RequestContext.FALSE_KEY_ID)) {
        return new BsonBoolean(false);
    }

    return null;
}
 
开发者ID:SoftInstigate,项目名称:restheart,代码行数:12,代码来源:URLUtils.java


示例20: Link

import org.bson.BsonBoolean; //导入依赖的package包/类
/**
 *
 * @param ref
 * @param href
 * @param templated
 */
public Link(String ref, String href, boolean templated) {
    this(ref, href);

    if (templated) {
        doc.getDocument(ref).put("templated", new BsonBoolean(true));
    }
}
 
开发者ID:SoftInstigate,项目名称:restheart,代码行数:14,代码来源:Link.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PullToRefreshView类代码示例发布时间:2022-05-21
下一篇:
Java StreamKeyValUtil类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap