如何从Datastore Google Cloud中检索文本类型? [英] How to retrieve Text type from Datastore Google Cloud?

本文介绍了如何从Datastore Google Cloud中检索文本类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,这些都是基本的问题,但在互联网上找不到很多答案。

好的,现在,我使用这个Java代码插入数据存储区

p>

  Text descriptionText = new Text(description); 
structureEntity.setUnindexedProperty(Description,descriptionText);

这里是检索代码:

 文本描述=(Text)structureObjectEntity.getProperty(Description); \ 
System.out.println(description);

现在,假设我插入我们应该在天黑之前到达。< ; br>我应该在周五之前完成这本书< br>今天的道路应该不那么拥挤。< br>< br>来源:http://www.oxfordlearnersdictionaries.com/definition/english/should?但是当检索数据时, System.out.println(description); / code> return <文字:我们应该在黑暗之前到达。< br>我应该已经完成​​Fr ...>的书了丢失了& < Text:在数据的头部<& c $ c> ... 在尾部的数据)&如何从Datastore Google Cloud中检索文本类型?

解决方案

您需要调用 getValue()方法。如果您将 Text 对象传递给 println(),它会调用 toString() / code>方法。 以下是Javadoc


Ok, These are all basic questions but there are not many answers found on the Internet.

OK, Now, I insert into Datastore using this Java code

Text descriptionText=new Text(description);
structureEntity.setUnindexedProperty("Description",descriptionText);

Anh here is the retrieving code:

Text description=(Text)structureObjectEntity.getProperty("Description");\
System.out.println(description);

Now, let say, I insert "We should arrive before dark.<br>I should have finished the book by Friday. <br>The roads should be less crowded today.<br><br>Source: http://www.oxfordlearnersdictionaries.com/definition/english/should?q=should" into Datastore

But when retrieving data, the System.out.println(description); return <Text: We should arrive before dark.<br>I should have finished the book by Fr...> (some data got lost & there is <Text: at the head of the data & ... at the tail of the data) & that messed up everything.

So, How to retrieve Text type from Datastore Google Cloud?

解决方案

You need to call the getValue() method. If you pass the Text object to println() it will call the toString() method. Here are the Javadocs

这篇关于如何从Datastore Google Cloud中检索文本类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆