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;
025
026 import microsoft.exchange.webservices.data.core.EwsServiceXmlReader;
027 import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter;
028 import microsoft.exchange.webservices.data.core.EwsUtilities;
029 import microsoft.exchange.webservices.data.core.XmlElementNames;
030 import microsoft.exchange.webservices.data.core.enumeration.property.MeetingResponseType;
031
032 import java.util.Date;
033
034 /**
035 * Represents an attendee to a meeting.
036 */
037
038 public final class Attendee extends EmailAddress {
039
040 /**
041 * The response type.
042 */
043 private MeetingResponseType responseType;
044
045 /**
046 * The last response time.
047 */
048 private Date lastResponseTime;
049
050 /**
051 * Initializes a new instance of the Attendee class.
052 */
053 public Attendee() {
054 super();
055 }
056
057 /**
058 * Initializes a new instance of the Attendee class.
059 *
060 * @param smtpAddress the smtp address
061 * @throws Exception the exception
062 */
063 public Attendee(String smtpAddress) throws Exception {
064 super(smtpAddress);
065 EwsUtilities.validateParam(smtpAddress, "smtpAddress");
066 }
067
068 /**
069 * Initializes a new instance of the Attendee class.
070 *
071 * @param name the name
072 * @param smtpAddress the smtp address
073 */
074 public Attendee(String name, String smtpAddress) {
075 super(name, smtpAddress);
076 }
077
078 /**
079 * Initializes a new instance of the Attendee class.
080 *
081 * @param name the name
082 * @param smtpAddress the smtp address
083 * @param routingType the routing type
084 */
085 public Attendee(String name, String smtpAddress, String routingType) {
086 super(name, smtpAddress, routingType);
087 }
088
089 /**
090 * Initializes a new instance of the Attendee class.
091 *
092 * @param mailbox the mailbox
093 * @throws Exception the exception
094 */
095 public Attendee(EmailAddress mailbox) throws Exception {
096 super(mailbox);
097 }
098
099 /**
100 * Gets the type of response the attendee gave to the meeting invitation
101 * it received.
102 *
103 * @return the response type
104 */
105 public MeetingResponseType getResponseType() {
106 return responseType;
107 }
108
109 /**
110 * Gets the last response time.
111 *
112 * @return the last response time
113 */
114 public Date getLastResponseTime() {
115 return lastResponseTime;
116 }
117
118 /**
119 * Tries to read element from XML.
120 *
121 * @param reader the reader
122 * @return True if element was read.
123 * @throws Exception the exception
124 */
125 public boolean tryReadElementFromXml(EwsServiceXmlReader reader)
126 throws Exception {
127 if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Mailbox)) {
128 this.loadFromXml(reader, reader.getLocalName());
129 return true;
130 } else if (reader.getLocalName().equalsIgnoreCase(
131 XmlElementNames.ResponseType)) {
132 this.responseType = reader
133 .readElementValue(MeetingResponseType.class);
134 return true;
135 } else if (reader.getLocalName().equalsIgnoreCase(
136 XmlElementNames.LastResponseTime)) {
137 this.lastResponseTime = reader.readElementValueAsDateTime();
138 return true;
139 } else {
140 return super.tryReadElementFromXml(reader);
141 }
142 }
143
144 /**
145 * Writes the elements to XML.
146 *
147 * @param writer the writer
148 * @throws Exception the exception
149 */
150 public void writeElementsToXml(EwsServiceXmlWriter writer)
151 throws Exception {
152 writer.writeStartElement(this.getNamespace(), XmlElementNames.Mailbox);
153 super.writeElementsToXml(writer);
154 writer.writeEndElement();
155 }
156 }