本文整理汇总了Java中com.mongodb.BasicDBList类的典型用法代码示例。如果您正苦于以下问题:Java BasicDBList类的具体用法?Java BasicDBList怎么用?Java BasicDBList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BasicDBList类属于com.mongodb包,在下文中一共展示了BasicDBList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import com.mongodb.BasicDBList; //导入依赖的package包/类
/**
* 解析
* @param group
* @param parser
* @return
*/
@Override
public Object parse(IGroup group, JsonRuleParser parser) {
// rules
BasicDBList operates = new BasicDBList();
for (JsonRule jsonRule : group.getRules()) {
operates.add(parser.parse(jsonRule));
}
// AND or OR
BasicDBObject andOrObj = new BasicDBObject();
andOrObj.append(EnumCondition.AND.equals(group.getCondition()) ? "$and" : "$or", operates);
// Not
if (group.getNot() != null && group.getNot()) {
BasicDBList list = new BasicDBList();
list.add(andOrObj);
return new BasicDBObject("$nor", list);
}
return andOrObj;
}
示例2: generateFile
import com.mongodb.BasicDBList; //导入依赖的package包/类
public void generateFile(String filename) {
DB db = MongoHelper.mongoMerchantDB();
DBCollection col = db.getCollection(COLLECTION_SYNONYMS);
DBCursor cursor = col.find();
try (PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(filename, true)))) {
while (cursor.hasNext()) {
DBObject doc = cursor.next();
String word = doc.get(FIELD_KEY_WORLD) != null ? doc.get(FIELD_KEY_WORLD).toString() : null;
String synonyms = doc.get(FIELD_KEY_WORLD) != null
? StringUtils.join((BasicDBList) doc.get(FIELD_KEY_SYNONYMS), ",") : null;
if (word != null && synonyms != null) {
out.println(createLine(word, synonyms));
}
}
} catch (IOException e) {
throw new RuntimeException("IOException: Current db cursor with id: " + cursor.curr().get("_id"), e);
}
}
示例3: toDBList
import com.mongodb.BasicDBList; //导入依赖的package包/类
public static BasicDBList toDBList(MultiNameValues multiNameValues)
{
String[] names = multiNameValues.getNames();
BasicDBList basicDBList = new BasicDBList();
for (int i = 0; i < multiNameValues.count(); i++)
{
Object[] values = multiNameValues.values(i);
BasicBSONObject bsonObject = new BasicBSONObject(values.length);
for (int j = 0; j < names.length; j++)
{
bsonObject.append(names[j], values[j]);
}
basicDBList.add(bsonObject);
}
return basicDBList;
}
示例4: parserDBObject
import com.mongodb.BasicDBList; //导入依赖的package包/类
private void parserDBObject(BasicDBObject ob,String akey, String aop,Object aval){
boolean isok=false;
if (!(ob.keySet().isEmpty())) {
for (String field : ob.keySet()) {
if (akey.equals(field)){
Object val = ob.get(field);
if (val instanceof BasicDBObject) {
((BasicDBObject) val).put(aop, aval);
ob.put(field, (BasicDBObject) val);
isok=true;
break;
} else if (val instanceof BasicDBList) {
// newobj.put(field, ((BasicDBList)val).copy());
}
}
}
}
if (isok==false) {
BasicDBObject xo = new BasicDBObject();
xo.put(aop, aval);
ob.put(akey,xo);
}
}
示例5: getDBObject
import com.mongodb.BasicDBList; //导入依赖的package包/类
/**
* Create a Mongo DB Object baed on the content of this group
*
* @param id The Mongo Object id to assign to this DB Object. If null, a new Object id will be
* created
* @return - The Mongo DB Object based on the content of this group
*/
public BasicDBObject getDBObject(boolean includeId) {
BasicDBObject group = new BasicDBObject();
if (includeId) {
group.append(DB_ID, new ObjectId(id));
}
group.append(JSON_KEY_GROUP_NAME, name);
BasicDBList membersArray = new BasicDBList();
for (int i = 0; i < members.length; i++) {
membersArray.add(members[i]);
}
group.append(JSON_KEY_MEMBERS_LIST, membersArray);
return group;
}
示例6: getDBObject
import com.mongodb.BasicDBList; //导入依赖的package包/类
/**
* Create a Mongo DB Object baed on the content of this group
*
* @param id The Mongo Object id to assign to this DB Object. If null, a new Object id will be
* created
* @return - The Mongo DB Object based on the content of this group
*/
public BasicDBObject getDBObject(boolean includeId) {
BasicDBObject group = new BasicDBObject();
if (includeId) {
group.append(DB_ID, new ObjectId(id));
}
group.append(JSON_KEY_GROUP_NAME, name);
BasicDBList membersArray = new BasicDBList();
for (int i = 0; i < members.length; i++) {
membersArray.add(members[i]);
}
group.append(JSON_KEY_MEMBERS_LIST, membersArray);
return group;
}
示例7: setQuery
import com.mongodb.BasicDBList; //导入依赖的package包/类
@Override
public void setQuery(DBObject query, BasicDBList orList) {
// if (null == orList) {
// query.put(this.name, value.getValue());
// } else {
// orList.add(new BasicDBObject(this.name, value.getValue()));
// }
if (this.name.equals("_id")) {
if (null == orList) {
query.put(this.name, new ObjectId(value.getValue().toString()));
} else {
orList.add(new BasicDBObject(this.name, new ObjectId(value.getValue().toString())));
}
} else {
if (null == orList) {
query.put(this.name, value.getValue());
} else {
orList.add(new BasicDBObject(this.name, value.getValue()));
}
}
}
示例8: mongoSerialise
import com.mongodb.BasicDBList; //导入依赖的package包/类
@Override
public BasicDBObject mongoSerialise() {
BasicDBObject dbObject = new BasicDBObject();
dbObject.put("i", getObjectId());
dbObject.put("x", getX());
dbObject.put("y", getY());
dbObject.put("t", ID);
BasicDBList tmpNpcArray = new BasicDBList();
for (NonPlayerCharacter npc : npcs) {
tmpNpcArray.add(npc.getObjectId());
}
dbObject.put("n", tmpNpcArray);
return dbObject;
}
示例9: mongoSerialise
import com.mongodb.BasicDBList; //导入依赖的package包/类
@Override
public BasicDBObject mongoSerialise() {
BasicDBList registers = new BasicDBList();
for (Integer index : this.registers.keySet()) {
JSONObject register = new JSONObject();
register.put("index", index);
register.put("name", getRegister(index).getName());
register.put("value", (int) getRegister(index).getValue());
registers.add(register);
}
BasicDBObject obj = new BasicDBObject();
obj.put("registers", registers);
return obj;
}
示例10: cryptFields
import com.mongodb.BasicDBList; //导入依赖的package包/类
void cryptFields(DBObject dbObject, Node node, Function<Object, Object> crypt) {
if (node.type == Node.Type.MAP) {
Node mapChildren = node.children.get(0);
for (Map.Entry<String, Object> entry : ((BasicDBObject) dbObject).entrySet()) {
cryptFields((DBObject) entry.getValue(), mapChildren, crypt);
}
return;
}
for (Node childNode : node.children) {
Object value = dbObject.get(childNode.fieldName);
if (value == null) continue;
if (!childNode.children.isEmpty()) {
if (value instanceof BasicDBList) {
for (Object o : (BasicDBList) value)
cryptFields((DBObject) o, childNode, crypt);
} else {
cryptFields((BasicDBObject) value, childNode, crypt);
}
return;
}
dbObject.put(childNode.fieldName, crypt.apply(value));
}
}
示例11: deleteUserSucceeds
import com.mongodb.BasicDBList; //导入依赖的package包/类
@Test
@DirtiesContext // because we can't authenticate twice on same DB
public void deleteUserSucceeds() throws MongoServiceException {
service.createDatabase(DB_NAME);
DBObject createUserCmd = BasicDBObjectBuilder.start("createUser", "user").add("pwd", "password")
.add("roles", new BasicDBList()).get();
CommandResult result = client.getDB(DB_NAME).command(createUserCmd);
assertTrue("create should succeed", result.ok());
service.deleteUser(DB_NAME, "user");
assertFalse(client.getDB(DB_NAME).authenticate("user", "password".toCharArray()));
}
示例12: toDBObject
import com.mongodb.BasicDBList; //导入依赖的package包/类
public DBObject toDBObject() {
DBObject out = new BasicDBObject();
if (name != null && type != null && typeInvite != null) {
out.put(FIELD_NAME, this.name);
out.put(FIELD_TYPE, this.type);
out.put(FIELD_TYPE_INVITE, this.typeInvite);
}
if (this.choices != null) {
BasicDBList dbList = new BasicDBList();
for (String choice : this.choices) {
dbList.add(choice);
}
out.put(FIELD_CHOICES, dbList);
}
if (this.label != null) {
out.put(FIELD_LABEL, this.label);
}
return out;
}
示例13: toDBObject
import com.mongodb.BasicDBList; //导入依赖的package包/类
public DBObject toDBObject() {
DBObject object = new BasicDBObject();
if (xType != null && type != null && attributes != null) {
object.put(FIELD_XTYPE, xType);
object.put(FIELD_TYPE, type);
object.put(FIELD_ICON, icon);
object.put(FIELD_ATTR, attributes.toDBObject());
}
if (terminals != null) {
BasicDBList dbList = new BasicDBList();
for (Terminal t : terminals) {
dbList.add(t.toDBObject());
}
object.put(FIELD_TERMINALS, dbList);
}
return object;
}
示例14: memoryToDBObject
import com.mongodb.BasicDBList; //导入依赖的package包/类
public DBObject memoryToDBObject() {
DBObject dbObj = this.toDBObject();
BasicDBList dbList = new BasicDBList();
if (fields != null) {
for (Field field : fields) {
dbList.add(field.toDBObject());
}
}
if (tickTuple != null) {
dbList.add(tickTuple.toDBObject());
}
dbObj.put(FIELD_FIELDS, dbList);
dbObj.put(FIELD_SINGLETON, singleton);
dbObj.put(FIELD_DESCRIPTION, description);
dbObj.put(FIELD_LANGUAGE, language);
if (versionCode > 0) {
dbObj.put(FIELD_VERSION_CODE, versionCode);
}
return dbObj;
}
示例15: Terminal
import com.mongodb.BasicDBList; //导入依赖的package包/类
public Terminal(DBObject o) {
if (o != null && o.get(FIELD_NAME) != null) {
name = o.get(FIELD_NAME).toString();
}
if (o != null && o.get(FIELD_N_MAX_WIRES) != null) {
nMaxWires = ((Integer) o.get(FIELD_N_MAX_WIRES));
}
if (o != null && o.get(FIELD_DIRECTIONS) != null) {
BasicDBList dbList = ((BasicDBList) o.get(FIELD_DIRECTIONS));
direction = new ArrayList<Integer>();
for (Object d : dbList) {
direction.add((new Double(d.toString())).intValue());
}
}
if (o != null) {
position = new OffsetPosition((DBObject) o.get(FIELD_POSITION));
}
if (o != null) {
ddConfig = new DdConfig((DBObject) o.get(FIELD_DD_CONFIG));
}
}