當前位置: 首頁>>代碼示例>>Java>>正文


Java BSONObject.containsField方法代碼示例

本文整理匯總了Java中org.bson.BSONObject.containsField方法的典型用法代碼示例。如果您正苦於以下問題:Java BSONObject.containsField方法的具體用法?Java BSONObject.containsField怎麽用?Java BSONObject.containsField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bson.BSONObject的用法示例。


在下文中一共展示了BSONObject.containsField方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getBean

import org.bson.BSONObject; //導入方法依賴的package包/類
@Override
public DataBean getBean(String key, String value) throws BeanException {
	DataBean bean;
	BSONObject datas = sqlHelper.findByKey(key, value);
	if(datas!=null && datas.containsField("id")){
		bean = new User(
				(String) datas.get("id"), 
				(String) datas.get("email"),
				(String) datas.get("pass"), 
				(String) datas.get("prenom"), 
				(String) datas.get("nom"),
				(String) datas.get("tag"));
		TransactionsUtils.applyTransactionsOnUser(bean);
		if(datas.containsField("token")){
			((User) bean).setToken((String) datas.get("token"));
		}
	}
	else
		bean = null;
	return bean;
}
 
開發者ID:steven89,項目名稱:if26_projet,代碼行數:22,代碼來源:SQLDatabase.java

示例2: hasRequiredFields

import org.bson.BSONObject; //導入方法依賴的package包/類
/**
 * check whether or not all the params needed are set
 * @param datas : datas to check
 * @param type : type of check to do {@value LoginManager#LOGIN}, {@value LoginManager#LOGOUT}, {@value LoginManager#AUTH}
 * @return true if all params are set
 */
private static boolean hasRequiredFields(BSONObject datas, int type){
	String[] requiredFields;
	switch (type) {
	case LoginManager.LOGIN:
		requiredFields = LoginManager.requiredLogin;
		break;
	case LoginManager.LOGOUT:
		requiredFields = LoginManager.requiredLogout;
		break;
	case LoginManager.AUTH:
		requiredFields = LoginManager.requiredAuth;
		break;
	default:
		requiredFields = LoginManager.requiredLogin;
		break;
	}
	for(String field : requiredFields){
		if(!datas.containsField(field))
			return false;
	}
	return true;
}
 
開發者ID:steven89,項目名稱:if26_projet,代碼行數:29,代碼來源:LoginManager.java

示例3: objectDone

import org.bson.BSONObject; //導入方法依賴的package包/類
@Override
public Object objectDone(){
    BSONObject o = (BSONObject)super.objectDone();
    String lastName = null;
    if ( _nameStack.size() > 0 ){
        lastName = _nameStack.removeLast();
    }
    if ( ! ( o instanceof List ) && lastName != null &&
         o.containsField( "$ref" ) &&
         o.containsField( "$id" ) ){
        return cur().put(lastName, new DBRef( _db, o ) );
    }

    return o;
}
 
開發者ID:MaOrKsSi,項目名稱:HZS.Durian,代碼行數:16,代碼來源:DefaultDBCallback.java

示例4: requireCoordinates

import org.bson.BSONObject; //導入方法依賴的package包/類
protected BasicDBList requireCoordinates(BSONObject bson) throws
        GeometryConverterException {
    if (!bson.containsField(COORDINATES_KEY)) {
        throw new GeometryConverterException("missing 'coordinates' field");
    }
    return toList(bson.get(COORDINATES_KEY));
}
 
開發者ID:enviroCar,項目名稱:enviroCar-server,代碼行數:8,代碼來源:GeoBSON.java

示例5: decodeGeometry

import org.bson.BSONObject; //導入方法依賴的package包/類
protected Geometry decodeGeometry(Object db) throws
        GeometryConverterException {
    BSONObject bson = (BSONObject) db;
    if (!bson.containsField(TYPE_KEY)) {
        throw new GeometryConverterException("Can not determine geometry type (missing 'type' field)");
    }
    Object to = bson.get(TYPE_KEY);
    if (!(to instanceof String)) {
        throw new GeometryConverterException("'type' field has to be a string");
    }
    String type = (String) to;
    if (type.equals(POINT_TYPE)) {
        return decodePoint(bson);
    } else if (type.equals(MULTI_POINT_TYPE)) {
        return decodeMultiPoint(bson);
    } else if (type.equals(LINE_STRING_TYPE)) {
        return decodeLineString(bson);
    } else if (type.equals(MULTI_LINE_STRING_TYPE)) {
        return decodeMultiLineString(bson);
    } else if (type.equals(POLYGON_TYPE)) {
        return decodePolygon(bson);
    } else if (type.equals(MULTI_POLYGON_TYPE)) {
        return decodeMultiPolygon(bson);
    } else if (type.equals(GEOMETRY_COLLECTION_TYPE)) {
        return decodeGeometryCollection(bson);
    } else {
        throw new GeometryConverterException("Unkown geometry type: " + type);
    }
}
 
開發者ID:enviroCar,項目名稱:enviroCar-server,代碼行數:30,代碼來源:GeoBSON.java

示例6: decodeGeometryCollection

import org.bson.BSONObject; //導入方法依賴的package包/類
@Override
public GeometryCollection decodeGeometryCollection(BSONObject bson) throws
        GeometryConverterException {
    if (!bson.containsField(GEOMETRIES_KEY)) {
        throw new GeometryConverterException("missing 'geometries' field");
    }
    BasicDBList geometries = toList(bson.get(GEOMETRIES_KEY));
    Geometry[] geoms = new Geometry[geometries.size()];
    for (int i = 0; i < geometries.size(); ++i) {
        geoms[i] = decodeGeometry(geometries.get(i));
    }
    return factory.createGeometryCollection(geoms);
}
 
開發者ID:enviroCar,項目名稱:enviroCar-server,代碼行數:14,代碼來源:GeoBSON.java

示例7: checkRequiredFields

import org.bson.BSONObject; //導入方法依賴的package包/類
/**
 * check if request datas have all required fields
 * @param args : required fields
 * @param datas : request datas
 * @return true if all required fields are set
 */
public static boolean checkRequiredFields(String[] args, BSONObject datas){
	for(String field : args){
		if(!datas.containsField(field) || datas.get(field)==null)
			return false;
	}
	return true;
}
 
開發者ID:steven89,項目名稱:if26_projet,代碼行數:14,代碼來源:ServletUtils.java


注:本文中的org.bson.BSONObject.containsField方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。