本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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));
}
示例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);
}
}
示例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);
}
示例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;
}