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.autodiscover;
025
026 import microsoft.exchange.webservices.data.core.EwsXmlReader;
027 import microsoft.exchange.webservices.data.core.XmlElementNames;
028 import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace;
029 import microsoft.exchange.webservices.data.security.XmlNodeType;
030
031 /**
032 * Defines the AlternateMailbox class.
033 */
034 public final class AlternateMailbox {
035
036 /**
037 * The type.
038 */
039 private String type;
040
041 /**
042 * The display name.
043 */
044 private String displayName;
045
046 /**
047 * The legacy dn.
048 */
049 private String legacyDN;
050
051 /**
052 * The server.
053 */
054 private String server;
055
056 /**
057 * Initializes a new instance of the AlternateMailbox class.
058 */
059 private AlternateMailbox() {
060 }
061
062 /**
063 * PLoads AlternateMailbox instance from XML.
064 *
065 * @param reader the reader
066 * @return AlternateMailbox
067 * @throws Exception the exception
068 */
069 public static AlternateMailbox loadFromXml(EwsXmlReader reader)
070 throws Exception {
071 AlternateMailbox altMailbox = new AlternateMailbox();
072
073 do {
074 reader.read();
075
076 if (reader.getNodeType().getNodeType() == XmlNodeType.START_ELEMENT) {
077 if (reader.getLocalName()
078 .equalsIgnoreCase(XmlElementNames.Type)) {
079 altMailbox.setType(reader.readElementValue(String.class));
080 } else if (reader.getLocalName().equalsIgnoreCase(
081 XmlElementNames.DisplayName)) {
082 altMailbox.setDisplayName(reader
083 .readElementValue(String.class));
084 } else if (reader.getLocalName().equalsIgnoreCase(
085 XmlElementNames.LegacyDN)) {
086 altMailbox.setLegacyDN(reader
087 .readElementValue(String.class));
088 } else if (reader.getLocalName().equalsIgnoreCase(
089 XmlElementNames.Server)) {
090 altMailbox.setServer(reader.readElementValue(String.class));
091 }
092 }
093 } while (!reader.isEndElement(XmlNamespace.Autodiscover,
094 XmlElementNames.AlternateMailbox));
095
096 return altMailbox;
097 }
098
099 /**
100 * Gets the alternate mailbox type.
101 *
102 * @return the type
103 */
104 public String getType() {
105 return type;
106 }
107
108 /**
109 * Sets the type.
110 *
111 * @param type the new type
112 */
113 protected void setType(String type) {
114 this.type = type;
115 }
116
117 /**
118 * Gets the alternate mailbox display name.
119 *
120 * @return the display name
121 */
122 public String getDisplayName() {
123 return displayName;
124 }
125
126 /**
127 * Sets the display name.
128 *
129 * @param displayName the new display name
130 */
131 protected void setDisplayName(String displayName) {
132 this.displayName = displayName;
133 }
134
135 /**
136 * Gets the alternate mailbox legacy DN.
137 *
138 * @return the legacy dn
139 */
140 public String getLegacyDN() {
141 return legacyDN;
142 }
143
144 /**
145 * Sets the legacy dn.
146 *
147 * @param legacyDN the new legacy dn
148 */
149 protected void setLegacyDN(String legacyDN) {
150 this.legacyDN = legacyDN;
151 }
152
153 /**
154 * Gets the alernate mailbox server.
155 *
156 * @return the server
157 */
158 public String getServer() {
159 return server;
160 }
161
162 /**
163 * Sets the server.
164 *
165 * @param server the new server
166 */
167 protected void setServer(String server) {
168 this.server = server;
169 }
170
171 }