001 /*
002 * The MIT License
003 * Copyright (c) 2012 Microsoft Corporation
004 *
005 * Permission is hereby granted, free of charge, to any person obtaining a copy
006 * of this software and associated documentation files (the "Software"), to deal
007 * in the Software without restriction, including without limitation the rights
008 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
009 * copies of the Software, and to permit persons to whom the Software is
010 * furnished to do so, subject to the following conditions:
011 *
012 * The above copyright notice and this permission notice shall be included in
013 * all copies or substantial portions of the Software.
014 *
015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
016 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
017 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
018 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
019 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
020 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
021 * THE SOFTWARE.
022 */
023
024 package microsoft.exchange.webservices.data.property.complex.availability;
025
026 import microsoft.exchange.webservices.data.core.EwsServiceXmlReader;
027 import microsoft.exchange.webservices.data.core.XmlElementNames;
028 import microsoft.exchange.webservices.data.core.enumeration.property.LegacyFreeBusyStatus;
029 import microsoft.exchange.webservices.data.property.complex.ComplexProperty;
030
031 import java.util.Date;
032
033 /**
034 * Represents an event in a calendar.
035 */
036 public final class CalendarEvent extends ComplexProperty {
037
038 /**
039 * The start time.
040 */
041 private Date startTime;
042
043 /**
044 * The end time.
045 */
046 private Date endTime;
047
048 /**
049 * The free busy status.
050 */
051 private LegacyFreeBusyStatus freeBusyStatus;
052
053 /**
054 * The details.
055 */
056 private CalendarEventDetails details;
057
058 /**
059 * Initializes a new instance of the CalendarEvent class.
060 */
061 public CalendarEvent() {
062 super();
063 }
064
065 /**
066 * Gets the start date and time of the event.
067 *
068 * @return the start time
069 */
070 public Date getStartTime() {
071 return startTime;
072 }
073
074 /**
075 * Gets the end date and time of the event.
076 *
077 * @return the end time
078 */
079 public Date getEndTime() {
080 return endTime;
081 }
082
083 /**
084 * Gets the free/busy status associated with the event.
085 *
086 * @return the free busy status
087 */
088 public LegacyFreeBusyStatus getFreeBusyStatus() {
089 return freeBusyStatus;
090 }
091
092 /**
093 * Gets the details of the calendar event. Details is null if the user
094 * requsting them does no have the appropriate rights.
095 *
096 * @return the details
097 */
098 public CalendarEventDetails getDetails() {
099 return details;
100 }
101
102 /**
103 * Attempts to read the element at the reader's current position.
104 *
105 * @param reader the reader
106 * @return True if the element was read, false otherwise.
107 * @throws Exception the exception
108 */
109 @Override
110 public boolean tryReadElementFromXml(EwsServiceXmlReader reader)
111 throws Exception {
112 if (reader.getLocalName().equals(XmlElementNames.StartTime)) {
113 this.startTime = reader
114 .readElementValueAsUnbiasedDateTimeScopedToServiceTimeZone();
115 return true;
116 } else if (reader.getLocalName().equals(XmlElementNames.EndTime)) {
117 this.endTime = reader
118 .readElementValueAsUnbiasedDateTimeScopedToServiceTimeZone();
119 return true;
120 } else if (reader.getLocalName().equals(XmlElementNames.BusyType)) {
121 this.freeBusyStatus = reader
122 .readElementValue(LegacyFreeBusyStatus.class);
123 return true;
124 }
125 if (reader.getLocalName().equals(XmlElementNames.CalendarEventDetails)) {
126 this.details = new CalendarEventDetails();
127 this.details.loadFromXml(reader, reader.getLocalName());
128 return true;
129 } else {
130 return false;
131 }
132
133 }
134 }