0
votes

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!!

1

1 Answers

0
votes

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.