本文整理了Java中com.mongodb.BasicDBObject.keySet()
方法的一些代码示例,展示了BasicDBObject.keySet()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BasicDBObject.keySet()
方法的具体详情如下:
包路径:com.mongodb.BasicDBObject
类名称:BasicDBObject
方法名:keySet
暂无
代码示例来源:origin: Graylog2/graylog2-server
@Override
public List<WidgetPosition> getPositions() {
final BasicDBObject positions = (BasicDBObject) fields.get(DashboardImpl.EMBEDDED_POSITIONS);
if (positions == null) {
return Collections.emptyList();
}
final List<WidgetPosition> result = new ArrayList<>(positions.size());
for ( String positionId : positions.keySet() ) {
final BasicDBObject position = (BasicDBObject) positions.get(positionId);
final int width = parseInt(position.get("width").toString());
final int height = parseInt(position.get("height").toString());
final int col = parseInt(position.get("col").toString());
final int row = parseInt(position.get("row").toString());
final WidgetPosition widgetPosition = WidgetPosition.builder()
.id(positionId)
.width(width)
.height(height)
.col(col)
.row(row)
.build();
result.add(widgetPosition);
}
return result;
}
代码示例来源:origin: org.mongodb/mongo-java-driver
@Override
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof BSONObject)) {
return false;
}
BSONObject other = (BSONObject) o;
if (!keySet().equals(other.keySet())) {
return false;
}
return Arrays.equals(toBson(canonicalizeBSONObject(this)), toBson(canonicalizeBSONObject(other)));
}
代码示例来源:origin: org.mongodb/mongo-java-driver
/**
* Creates a new instance which is a copy of this BasicDBObject.
*
* @return a BasicDBObject with exactly the same values as this instance.
*/
public Object copy() {
// copy field values into new object
BasicDBObject newCopy = new BasicDBObject(this.toMap());
// need to clone the sub obj
for (final String field : keySet()) {
Object val = get(field);
if (val instanceof BasicDBObject) {
newCopy.put(field, ((BasicDBObject) val).copy());
} else if (val instanceof BasicDBList) {
newCopy.put(field, ((BasicDBList) val).copy());
}
}
return newCopy;
}
代码示例来源:origin: Impetus/Kundera
private void addLookupAndMatchToPipeline(BasicDBList lookup, BasicDBObject mongoQuery, List<DBObject> pipeline)
{
BasicDBObject matchBeforeLookup = new BasicDBObject();
BasicDBObject matchAfterLookup = new BasicDBObject();
for (String key : mongoQuery.keySet())
{
if (key.contains("."))
{
matchAfterLookup.append(key, mongoQuery.get(key));
}
else
{
matchBeforeLookup.append(key, mongoQuery.get(key));
}
}
if (matchBeforeLookup.size() > 0)
{
pipeline.add(new BasicDBObject("$match", matchBeforeLookup));
}
for (Object lookupItem : lookup)
{
pipeline.add((DBObject) lookupItem);
}
if (matchAfterLookup.size() > 0)
{
pipeline.add(new BasicDBObject("$match", matchAfterLookup));
}
}
代码示例来源:origin: Impetus/Kundera
Set<String> set = obj.keySet(); // Set containing index name which
代码示例来源:origin: Impetus/Kundera
for (String key : orderBy.keySet())
代码示例来源:origin: eBay/YiDB
private String getKey(BasicDBObject dbo) {
for (String key : dbo.keySet()) {
if (!key.equals("_id")) {
return key;
}
}
return null;
}
}
代码示例来源:origin: mongodb-labs/socialite
@Override
public String toString() {
StringBuilder builder = new StringBuilder(this.errorCode.toString());
for(String propKey : properties.keySet()){
builder.append("\n\t");
builder.append(propKey);
builder.append(" : ");
builder.append(properties.get(propKey));
}
return builder.toString();
}
}
代码示例来源:origin: mongodb-labs/hvdf
@Override
public String toString() {
StringBuilder builder = new StringBuilder(this.errorCode.toString());
if(this.getMessage() != null){
builder.append(" : ");
builder.append(this.getMessage());
}
for(String propKey : properties.keySet()){
builder.append("\n\t");
builder.append(propKey);
builder.append(" : ");
builder.append(properties.get(propKey));
}
return builder.toString();
}
}
代码示例来源:origin: eBay/YiDB
@Override
public Collection<String> getFieldNames(){
Collection<String> fielNames = new ArrayList<String>(bsonObject.size() * 2);
for(String dbName : bsonObject.keySet()){
MetaField metaField = getMetaClass().getFieldByDbName(dbName);
if (metaField != null) {
String fieldName = metaField.getName();
fielNames.add(fieldName);
}
}
return fielNames;
}
代码示例来源:origin: eBay/YiDB
@Override
public Collection<String> getFieldNames(){
Collection<String> fielNames = new HashSet<String>(bsonObject.size() * 2);
for(String dbName : bsonObject.keySet()){
MetaField metaField = getMetaClass().getFieldByFlattenValueDbName(dbName);
if (metaField != null) {
String fieldName = metaField.getName();
fielNames.add(fieldName);
}
}
return fielNames;
}
代码示例来源:origin: com.effektif/effektif-mongo
/**
* Reads database fields (that do not have Java fields) and copies them to workflow instance properties.
* This makes it possible to write non-standard fields to the database and read them from properties.
*/
private void copyProperties(BasicDBObject dbWorkflowInstance, WorkflowInstanceImpl workflowInstance) {
if (dbWorkflowInstance == null || workflowInstance == null) {
return;
}
Set<String> invalidPropertyKeys = Extensible.getInvalidPropertyKeys(WorkflowInstance.class);
// Map<String,?> mappedBeanFields = mongoMapper.write(workflowInstance.toWorkflowInstance());
for (String fieldName : dbWorkflowInstance.keySet()) {
boolean property = !invalidPropertyKeys.contains(fieldName);
if (property) {
workflowInstance.setProperty(fieldName, dbWorkflowInstance.get(fieldName));
}
}
}
代码示例来源:origin: effektif/effektif
/**
* Reads database fields (that do not have Java fields) and copies them to workflow instance properties.
* This makes it possible to write non-standard fields to the database and read them from properties.
*/
private void copyProperties(BasicDBObject dbWorkflowInstance, WorkflowInstanceImpl workflowInstance) {
if (dbWorkflowInstance == null || workflowInstance == null) {
return;
}
Set<String> invalidPropertyKeys = Extensible.getInvalidPropertyKeys(WorkflowInstance.class);
// Map<String,?> mappedBeanFields = mongoMapper.write(workflowInstance.toWorkflowInstance());
for (String fieldName : dbWorkflowInstance.keySet()) {
boolean property = !invalidPropertyKeys.contains(fieldName);
if (property) {
workflowInstance.setProperty(fieldName, dbWorkflowInstance.get(fieldName));
}
}
}
代码示例来源:origin: org.mongodb/mongodb-driver-core
@Override
public boolean equals(final Object o) {
if (o == this) {
return true;
}
if (!(o instanceof BSONObject)) {
return false;
}
BSONObject other = (BSONObject) o;
if (!keySet().equals(other.keySet())) {
return false;
}
return Arrays.equals(toBson(canonicalizeBSONObject(this)), toBson(canonicalizeBSONObject(other)));
}
代码示例来源:origin: pl.edu.icm.synat/synat-core-services-impl
public List<YAttribute> convert(BasicDBObject source) {
List<YAttribute> attributes = new ArrayList<>();
for (String key : source.keySet()) {
if(getConverter().getTypeMapper().isTypeKey(key)){
continue;
}
Object value = source.get(key);
key = getConverter().potentiallyUnescapeMapKey(key);
attributes.addAll(processAttributes(key, value));
}
return attributes;
}
代码示例来源:origin: org.mongodb/mongodb-driver-core
/**
* Creates a new instance which is a copy of this BasicDBObject.
*
* @return a BasicDBObject with exactly the same values as this instance.
*/
public Object copy() {
// copy field values into new object
BasicDBObject newCopy = new BasicDBObject(this.toMap());
// need to clone the sub obj
for (final String field : keySet()) {
Object val = get(field);
if (val instanceof BasicDBObject) {
newCopy.put(field, ((BasicDBObject) val).copy());
} else if (val instanceof BasicDBList) {
newCopy.put(field, ((BasicDBList) val).copy());
}
}
return newCopy;
}
代码示例来源:origin: eBay/YiDB
@Override
public Collection<String> getFieldNames(){
Collection<String> fielNames = new ArrayList<String>(bsonObject.size() * 2);
for(String dbName : bsonObject.keySet()){
MetaField metaField = getMetaClass().getFieldByDbName(dbName);
if (metaField != null) {
String fieldName = metaField.getName();
fielNames.add(fieldName);
}
}
return fielNames;
}
代码示例来源:origin: eBay/YiDB
public void loadProperties(InputStream is) {
DBCollection propertiesCollection = mongo.getDB(CMSConsts.SYS_DB).getCollection(CMSConsts.PROPERTIES_COLLECTION);
//load properties collection
BasicDBObject cmsProperties = (BasicDBObject)loadBasonFromFile(is);
for (String key : cmsProperties.keySet()) {
DBObject obj = new BasicDBObject().append(key, cmsProperties.get(key));
propertiesCollection.insert(obj);
}
}
代码示例来源:origin: org.keycloak/keycloak-model-mongo
static Event convertEvent(BasicDBObject o) {
Event event = new Event();
event.setTime(o.getLong("time"));
event.setType(EventType.valueOf(o.getString("type")));
event.setRealmId(o.getString("realmId"));
event.setClientId(o.getString("clientId"));
event.setUserId(o.getString("userId"));
event.setSessionId(o.getString("sessionId"));
event.setIpAddress(o.getString("ipAddress"));
event.setError(o.getString("error"));
BasicDBObject d = (BasicDBObject) o.get("details");
if (d != null) {
Map<String, String> details = new HashMap<String, String>();
for (Object k : d.keySet()) {
details.put((String) k, d.getString((String) k));
}
event.setDetails(details);
}
return event;
}
代码示例来源:origin: eBay/YiDB
private void buildJsonBody(DBObject modifyBody) {
BasicDBObject set = (BasicDBObject) modifyBody.get("$set");
MetaField field = getField();
BasicDBObject enityObject = (BasicDBObject) getEntity().getNode();
BasicDBObject fieldObject = (BasicDBObject) enityObject.get(field.getFlattenValueDbName());
if (fieldObject != null) {
BasicDBObject givenValue = fieldObject;
if (givenValue != null) {
for (String key : givenValue.keySet()) {
set.put(field.getFlattenValueDbName() + DOT + key, givenValue.get(key));
}
// field properties
// no length here
set.put(field.getFlattenPropertyValueDbName(FieldProperty.TIMESTAMP), getEntity().getFieldTimestamp(field.getName()));
}
}
}
内容来源于网络,如有侵权,请联系作者删除!