本文整理了Java中com.google.cloud.datastore.Entity.getBlob()
方法的一些代码示例,展示了Entity.getBlob()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.getBlob()
方法的具体详情如下:
包路径:com.google.cloud.datastore.Entity
类名称:Entity
方法名:getBlob
暂无
代码示例来源:origin: google/data-transfer-project
private static Map<String, Object> getProperties(Entity entity)
throws IOException, ClassNotFoundException {
if (entity == null) {
return null;
}
ImmutableMap.Builder<String, Object> builder = new ImmutableMap.Builder<>();
for (String property : entity.getNames()) {
// builder.put(property, entity.getValue(property));
if (entity.getValue(property) instanceof StringValue) {
builder.put(property, (String) entity.getString(property));
} else if (entity.getValue(property) instanceof LongValue) {
// This conversion is safe because of integer to long conversion above
builder.put(property, new Long(entity.getLong(property)).intValue());
} else if (entity.getValue(property) instanceof DoubleValue) {
builder.put(property, (Double) entity.getDouble(property));
} else if (entity.getValue(property) instanceof BooleanValue) {
builder.put(property, (Boolean) entity.getBoolean(property));
} else if (entity.getValue(property) instanceof TimestampValue) {
builder.put(property, (Timestamp) entity.getTimestamp(property));
} else {
Blob blob = entity.getBlob(property);
Object obj = null;
try (ObjectInputStream in = new ObjectInputStream(blob.asInputStream())) {
obj = in.readObject();
}
builder.put(property, obj); // BlobValue
}
}
return builder.build();
}
代码示例来源:origin: org.eclipse.jetty.gcloud/jetty-gcloud-session-manager
Blob blob = (Blob) entity.getBlob(_model.getAttributes());
内容来源于网络,如有侵权,请联系作者删除!