本文整理汇总了Java中com.couchbase.lite.Document.getProperties方法的典型用法代码示例。如果您正苦于以下问题:Java Document.getProperties方法的具体用法?Java Document.getProperties怎么用?Java Document.getProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.couchbase.lite.Document
的用法示例。
在下文中一共展示了Document.getProperties方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onItemClick
import com.couchbase.lite.Document; //导入方法依赖的package包/类
/**
* Handle click on item in list
*/
public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
// Step 10 code goes here
// This code handles checkbox touches. Couchbase Lite documents are like versioned-maps.
// To change a Document, add a new Revision.
QueryRow row = (QueryRow) adapterView.getItemAtPosition(position);
Document document = row.getDocument();
Map<String, Object> newProperties = new HashMap<String, Object>(document.getProperties());
boolean checked = ((Boolean) newProperties.get("check")).booleanValue();
newProperties.put("check", !checked);
try {
document.putProperties(newProperties);
kitchenSyncArrayAdapter.notifyDataSetChanged();
} catch (Exception e) {
Toast.makeText(getApplicationContext(), "Error updating database, see logs for details", Toast.LENGTH_LONG).show();
Log.e(TAG, "Error updating database", e);
}
}
示例2: onKickOff
import com.couchbase.lite.Document; //导入方法依赖的package包/类
@Override
protected void onKickOff() {
super.onKickOff();
String id = getArguments().getString("id");
final String email = getArguments().getString("email");
Document document = dataService.loadDocument(id);
final Map<String, Object> selectedContact;
if (document != null) {
selectedContact = document.getProperties();
} else {
selectedContact = null;
}
((TextView) getDialog().findViewById(android.R.id.message)).setText("Add " + (selectedContact != null ? selectedContact.get("email") : email) + "as contact?");
}
示例3: setProperty
import com.couchbase.lite.Document; //导入方法依赖的package包/类
public static void setProperty(final Document document, final String property, final Object value) {
Map<String, Object> properties = new HashMap<String, Object>(document.getProperties());
properties.put(property, value);
UnsavedRevision revision = document.createRevision();
revision.setProperties(properties);
try {
revision.save();
} catch (CouchbaseLiteException e) {
throw new RuntimeException(e);
}
}
示例4: setProperties
import com.couchbase.lite.Document; //导入方法依赖的package包/类
public static void setProperties(final Document document, final Map<String, Object> newProperties) {
Map<String, Object> properties = new HashMap<String, Object>(document.getProperties());
properties.putAll(newProperties);
UnsavedRevision revision = document.createRevision();
revision.setProperties(properties);
try {
revision.save();
} catch (CouchbaseLiteException e) {
throw new RuntimeException(e);
}
}
示例5: queryItemsByIds
import com.couchbase.lite.Document; //导入方法依赖的package包/类
/**
* 查询指定的json对象,以字符串形式返回
* view 查询的version 为1
*
* @param ids
* @param dataType
* @return
*/
@Override
public List<Map<String, Object>> queryItemsByIds(final String dataType, Object... ids) {
List<Map<String, Object>> datas = new ArrayList<>();
View phoneView = mDatabase.getView(dataType);
if (phoneView != null) {
//建立索引,只建立一次
indexView(phoneView, dataType);
Query query = phoneView.createQuery();
query.setKeys(Arrays.<Object>asList(ids));
query.setLimit(ids.length);
try {
QueryEnumerator qe = query.run();
for (Iterator<QueryRow> it = qe; it.hasNext(); ) {
QueryRow row = it.next();
Document doc = row.getDocument();
Map<String, Object> map = doc.getProperties();
if (map != null && map.size() > 0) {
datas.add(map);
}
}
} catch (Exception e) {
LogUtils.e(e);
}
}
return datas;
}
示例6: queryItemsByTypes
import com.couchbase.lite.Document; //导入方法依赖的package包/类
@Override
public List<Map<String, Object>> queryItemsByTypes(final String dataType) {
List<Map<String, Object>> datas = new ArrayList<>();
View phoneView = mDatabase.getView(dataType);
if (phoneView != null) {
//建立索引,只建立一次
indexView(phoneView, dataType);
Query query = phoneView.createQuery();
try {
QueryEnumerator qe = query.run();
for (Iterator<QueryRow> it = qe; it.hasNext(); ) {
QueryRow row = it.next();
Document doc = row.getDocument();
Map<String, Object> map = doc.getProperties();
if (map != null && map.size() > 0) {
datas.add(map);
}
}
} catch (Exception e) {
LogUtils.e(e);
String s = e.getMessage();
}
}
return datas;
}
示例7: insert
import com.couchbase.lite.Document; //导入方法依赖的package包/类
@Override
public Map<String, Object> insert(Map<String, Object> map) throws PersistenceException {
try {
// Create a new document
Document doc = database.createDocument();
doc.putProperties(map);
return doc.getProperties();
} catch (Exception e) {
throw new PersistenceException("Ouch. couldn't store that document.", e);
}
}
开发者ID:benwilcock,项目名称:android-couchbase-dagger-robolectric,代码行数:13,代码来源:CouchbasePersistenceAdapter.java
示例8: toObject
import com.couchbase.lite.Document; //导入方法依赖的package包/类
public <T> T toObject(Document document) {
final Map<String, Object> properties = document.getProperties();
final String sDocumentType = (String) properties.get("type");
if (sDocumentType == null) {
throw new IllegalArgumentException("The document " + document.getId() + " doesn't have set the \"type\" property.");
}
@SuppressWarnings("unchecked")
final Mapper<T> mapper = (Mapper<T>) stringToMapper.get(sDocumentType);
if (mapper == null) {
throw new IllegalArgumentException("Unknown type " + sDocumentType + " at document " + document.getId() + ".");
}
return mapper.toObject(properties);
}