本文整理汇总了Java中com.google.api.services.calendar.model.CalendarList类的典型用法代码示例。如果您正苦于以下问题:Java CalendarList类的具体用法?Java CalendarList怎么用?Java CalendarList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CalendarList类属于com.google.api.services.calendar.model包,在下文中一共展示了CalendarList类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCalendar
import com.google.api.services.calendar.model.CalendarList; //导入依赖的package包/类
/**
* retrieves the calendar for the given name (summary)
*
* @return den Kalender
*/
private com.google.api.services.calendar.model.Calendar getCalendar() {
if (calendar == null) {
final com.google.api.services.calendar.Calendar myService = settings.getGoogleCalendarService();
try {
final CalendarList list = myService.calendarList().list().execute();
for (final CalendarListEntry entry : list.getItems()) {
if (settings.getGoogleCalendarName().equals(entry.getSummary())) {
final String id = entry.getId();
calendar = myService.calendars().get(id).execute();
break;
}
}
} catch (final IOException e) {
throw new SynchronisationException(e);
}
if (calendar == null) {
// calendar with given name does not exist
throw new SynchronisationException(UserMessage.get().GOOGLE_CALENDAR_S_DOES_NOT_EXIST_CHECK_CONFIG(settings.getGoogleCalendarName()));
}
}
return calendar;
}
示例2: getCalendar
import com.google.api.services.calendar.model.CalendarList; //导入依赖的package包/类
private static CalendarListEntry getCalendar() throws IOException {
final CalendarList feed = client.calendarList().list().execute();
for (final CalendarListEntry c : feed.getItems()) {
if (c.getSummary().equalsIgnoreCase("flats")) {
return c;
}
}
return null;
}
示例3: isCalendarInList
import com.google.api.services.calendar.model.CalendarList; //导入依赖的package包/类
protected boolean isCalendarInList(Calendar calendar) {
CalendarList calendarList = requestBody("direct://LIST", null);
java.util.List<CalendarListEntry> items = calendarList.getItems();
boolean found = false;
for (CalendarListEntry calendarListEntry : items) {
if (calendar.getSummary().equals(calendarListEntry.getSummary())) {
found = true;
}
}
return found;
}
示例4: fetchCalendars
import com.google.api.services.calendar.model.CalendarList; //导入依赖的package包/类
/***
* Gets a lists of all calendars in the client instance and returns it.
* @return List of calendars
* @throws IOException
*/
public CalendarList fetchCalendars() throws IOException{
return client.calendarList().list().execute();
}
示例5: update
import com.google.api.services.calendar.model.CalendarList; //导入依赖的package包/类
@Override
public Map<Thermostat, SortedMap<Period, ZoneStatus>> update() throws IOException {
NDC.push("update");
Marker m = new Marker("update");
Map<Thermostat, SortedMap<Period, ZoneStatus>> ts2schedule = new TreeMap<Thermostat, SortedMap<Period, ZoneStatus>>();
try {
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
FileDataStoreFactory dataStoreFactory = new FileDataStoreFactory(new File(System.getProperty("user.home"), STORED_CREDENTIALS));
m.checkpoint("instantiated tools");
Credential credential = authorize(httpTransport, jsonFactory, dataStoreFactory);
m.checkpoint("authorized");
// VT: NOTE: There's no need for us to do this more often than we really need.
// I'd assume that once a year would be just fine. Maybe a bit too often, but come on, let's be realistic,
// users need some extra fun.
credential.setExpiresInSeconds(60L * 60L * 24L * 365L);
Calendar calendarClient = new Calendar.Builder(httpTransport, jsonFactory, credential).setApplicationName(LITERAL_APP_NAME).build();
m.checkpoint("instantiated client");
CalendarList feed = calendarClient.calendarList().list().execute();
List<CalendarListEntry> calendars = feed.getItems();
m.checkpoint("retrieved feed");
logger.info(calendars.size() + " calendars found:");
for (Iterator<CalendarListEntry> i = calendars.iterator(); i.hasNext(); ) {
CalendarListEntry c = i.next();
logger.info(" calendar: " + c.getSummary());
}
m.checkpoint("retrieved summary");
for (Iterator<CalendarListEntry> i = calendars.iterator(); i.hasNext(); ) {
CalendarListEntry calendar = i.next();
updateCalendar(ts2schedule, calendarClient, calendar);
}
NDC.push("schedule");
for (Iterator<Entry<Thermostat, SortedMap<Period, ZoneStatus>>> i = ts2schedule.entrySet().iterator(); i.hasNext(); ) {
Entry<Thermostat, SortedMap<Period, ZoneStatus>> pair = i.next();
logger.info(pair.getKey().getName() + ": " + pair.getValue().size() + " entries");
for (Iterator<Entry<Period, ZoneStatus>> i2 = pair.getValue().entrySet().iterator(); i2.hasNext(); ) {
logger.info(" " + i2.next());
}
}
NDC.pop();
return ts2schedule;
} catch (GeneralSecurityException ex) {
throw new IllegalStateException("Oops", ex);
} finally {
m.close();
NDC.pop();
}
}