Google 日历,获取位置?
我正在使用 JAVA 和 gdata api 在 Google 日历上工作。 我正在尝试从公共日历中检索活动位置。这是我的方法:
private static void getCalendarEvents (CalendarService service, URL feedURL)
throws IOException, ServiceException{
CalendarFeed resultFeed = service.getFeed(feedURL, CalendarFeed.class);
for(int i = 0; i < resultFeed.getEntries().size(); i++){
CalendarEntry entry = resultFeed.getEntries().get(i);
System.out.println("\t" + entry.getLocations());
}
在我的控制台中,对于“entry.getLocation()”部分,我不断获得如下输出:
[com.google.gdata.data.extensions.Where@1f3785d3]
[com.google.gdata.data.extensions.Where@1f3785d3]
....
根据描述,该方法应该返回 List 类型,但显然我没有得到它。 有人知道为什么我会得到这个值吗?或者说如何获取正确的返回值?
另请参阅 Google 代码上的 CalendarEntry.class 代码: http://www .google.com/codesearch#EOYaOg_yTgg/trunk/java/src/com/google/gdata/data/calendar/CalendarEntry.java
谢谢 很多。
嗯,谢谢!我在这里发布了未能检索事件日期的代码,请查看。 首先是我的 getEventDates.class 返回 When 对象的列表:
private static List<When> getEventDates(CalendarEntry entry){
return entry.getRepeatingExtension(When.class);
}
我在下面调用它:
for(int i = 0; i < resultFeed.getEntries().size(); i++){
CalendarEntry entry = resultFeed.getEntries().get(i);
List<When> timeList = getEventDates(entry);
System.out.println("\t" + i+". "+entry.getTitle().getPlainText() + "\t" + timeList.get(0).getValueString());
}
这完成了工作...这意味着,我在 timeList 中得到了所有“null”。 我只想得到 xml 中的内容,请给我一些提示。 多谢!!
I'm using JAVA and gdata api working on Google Calendar.
I'm trying to retrieve event location from a public Calendar. here's my approach:
private static void getCalendarEvents (CalendarService service, URL feedURL)
throws IOException, ServiceException{
CalendarFeed resultFeed = service.getFeed(feedURL, CalendarFeed.class);
for(int i = 0; i < resultFeed.getEntries().size(); i++){
CalendarEntry entry = resultFeed.getEntries().get(i);
System.out.println("\t" + entry.getLocations());
}
and in my Console, for the "entry.getLocation()" part, I kept getting outputs like following:
[com.google.gdata.data.extensions.Where@1f3785d3]
[com.google.gdata.data.extensions.Where@1f3785d3]
....
According to the description, the method should return a List type but apparently I didnt get it.
Anyone has any idea why I'm getting this value? Or how can I access to the correct return value?
Please also see the code of CalendarEntry.class here on Google Code:
http://www.google.com/codesearch#EOYaOg_yTgg/trunk/java/src/com/google/gdata/data/calendar/CalendarEntry.java
Thanks a lot.
Well thank you! I'm posting my code that failed retrieving event's date here, please take a look.
First is my getEventDates.class returns a list of When objects:
private static List<When> getEventDates(CalendarEntry entry){
return entry.getRepeatingExtension(When.class);
}
and I call it below:
for(int i = 0; i < resultFeed.getEntries().size(); i++){
CalendarEntry entry = resultFeed.getEntries().get(i);
List<When> timeList = getEventDates(entry);
System.out.println("\t" + i+". "+entry.getTitle().getPlainText() + "\t" + timeList.get(0).getValueString());
}
this donest work... which means, I got all "null"s in timeList.
I just want to have the contents in the xml, Please give me some hint.
Thanks a Lot!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对entry.getLocations() 的调用返回可迭代的Where 对象的列表。
例如,您可以使用每个Where实例的getValueString()方法来获取包含位置文本描述的字符串。
请参阅 http://code.google.com/p/gdata-java-client/source/browse/trunk/java/src/com/google/gdata/data/extensions/Where.java 用于定义Where 类。
The call to entry.getLocations() returns a list of Where objects that you can iterate.
For example, you can use the getValueString() method of each Where instance to get a string containing the text description of the location.
See http://code.google.com/p/gdata-java-client/source/browse/trunk/java/src/com/google/gdata/data/extensions/Where.java for the definition the Where class.