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.XmlElementNames;
029 import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace;
030
031 /**
032 * Represents the complete name of a contact.
033 */
034 public final class CompleteName extends ComplexProperty {
035
036 /**
037 * The title.
038 */
039 private String title;
040
041 /**
042 * The given name.
043 */
044 private String givenName;
045
046 /**
047 * The middle name.
048 */
049 private String middleName;
050
051 /**
052 * The surname.
053 */
054 private String surname;
055
056 /**
057 * The suffix.
058 */
059 private String suffix;
060
061 /**
062 * The initials.
063 */
064 private String initials;
065
066 /**
067 * The full name.
068 */
069 private String fullName;
070
071 /**
072 * The nickname.
073 */
074 private String nickname;
075
076 /**
077 * The yomi given name.
078 */
079 private String yomiGivenName;
080
081 /**
082 * The yomi surname.
083 */
084 private String yomiSurname;
085
086 /**
087 * Gets the contact's title.
088 *
089 * @return the title
090 */
091 public String getTitle() {
092 return title;
093 }
094
095 /**
096 * Gets the given name (first name) of the contact.
097 *
098 * @return the givenName
099 */
100 public String getGivenName() {
101 return givenName;
102 }
103
104 /**
105 * Gets the middle name of the contact.
106 *
107 * @return the middleName
108 */
109 public String getMiddleName() {
110 return middleName;
111 }
112
113 /**
114 * Gets the surname (last name) of the contact.
115 *
116 * @return the surname
117 */
118 public String getSurname() {
119 return surname;
120 }
121
122 /**
123 * Gets the suffix of the contact.
124 *
125 * @return the suffix
126 */
127 public String getSuffix() {
128 return suffix;
129 }
130
131 /**
132 * Gets the initials of the contact.
133 *
134 * @return the initials
135 */
136 public String getInitials() {
137 return initials;
138 }
139
140 /**
141 * Gets the full name of the contact.
142 *
143 * @return the fullName
144 */
145 public String getFullName() {
146 return fullName;
147 }
148
149 /**
150 * Gets the nickname of the contact.
151 *
152 * @return the nickname
153 */
154 public String getNickname() {
155 return nickname;
156 }
157
158 /**
159 * Gets the Yomi given name (first name) of the contact.
160 *
161 * @return the yomiGivenName
162 */
163 public String getYomiGivenName() {
164 return yomiGivenName;
165 }
166
167 /**
168 * Gets the Yomi surname (last name) of the contact.
169 *
170 * @return the yomiSurname
171 */
172 public String getYomiSurname() {
173 return yomiSurname;
174 }
175
176 /**
177 * Tries to read element from XML.
178 *
179 * @param reader The reader.
180 * @return True if element was read.
181 * @throws Exception the exception
182 */
183 @Override
184 public boolean tryReadElementFromXml(EwsServiceXmlReader reader)
185 throws Exception {
186
187 if (reader.getLocalName().equalsIgnoreCase(XmlElementNames.Title)) {
188 this.title = reader.readElementValue();
189 return true;
190 } else if (reader.getLocalName().equalsIgnoreCase(
191 XmlElementNames.FirstName)) {
192 this.givenName = reader.readElementValue();
193 return true;
194 } else if (reader.getLocalName().equalsIgnoreCase(
195 XmlElementNames.MiddleName)) {
196 this.middleName = reader.readElementValue();
197 return true;
198 } else if (reader.getLocalName().equalsIgnoreCase(
199 XmlElementNames.LastName)) {
200 this.surname = reader.readElementValue();
201 return true;
202 } else if (reader.getLocalName().equalsIgnoreCase(
203 XmlElementNames.Suffix)) {
204 this.suffix = reader.readElementValue();
205 return true;
206 } else if (reader.getLocalName().equalsIgnoreCase(
207 XmlElementNames.Initials)) {
208 this.initials = reader.readElementValue();
209 return true;
210 } else if (reader.getLocalName().equalsIgnoreCase(
211 XmlElementNames.FullName)) {
212 this.fullName = reader.readElementValue();
213 return true;
214 } else if (reader.getLocalName().equalsIgnoreCase(
215 XmlElementNames.NickName)) {
216 this.nickname = reader.readElementValue();
217 return true;
218 } else if (reader.getLocalName().equalsIgnoreCase(
219 XmlElementNames.YomiFirstName)) {
220 this.yomiGivenName = reader.readElementValue();
221 return true;
222 } else if (reader.getLocalName().equalsIgnoreCase(
223 XmlElementNames.YomiLastName)) {
224 this.yomiSurname = reader.readElementValue();
225 return true;
226 } else {
227 return false;
228 }
229 }
230
231 /**
232 * Writes the elements to XML.
233 *
234 * @param writer accepts EwsServiceXmlWriter
235 * @throws Exception throws Exception
236 */
237 @Override
238 public void writeElementsToXml(EwsServiceXmlWriter writer)
239 throws Exception {
240 writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Title,
241 this.title);
242 writer.writeElementValue(XmlNamespace.Types, XmlElementNames.FirstName,
243 this.givenName);
244 writer.writeElementValue(XmlNamespace.Types,
245 XmlElementNames.MiddleName, this.middleName);
246 writer.writeElementValue(XmlNamespace.Types, XmlElementNames.LastName,
247 this.surname);
248 writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Suffix,
249 this.suffix);
250 writer.writeElementValue(XmlNamespace.Types, XmlElementNames.Initials,
251 this.initials);
252 writer.writeElementValue(XmlNamespace.Types, XmlElementNames.FullName,
253 this.fullName);
254 writer.writeElementValue(XmlNamespace.Types, XmlElementNames.NickName,
255 this.nickname);
256 writer.writeElementValue(XmlNamespace.Types,
257 XmlElementNames.YomiFirstName, this.yomiGivenName);
258 writer.writeElementValue(XmlNamespace.Types,
259 XmlElementNames.YomiLastName, this.yomiSurname);
260 }
261 }