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
024package microsoft.exchange.webservices.data.misc.id;
025
026import microsoft.exchange.webservices.data.core.EwsServiceXmlReader;
027import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter;
028import microsoft.exchange.webservices.data.core.XmlAttributeNames;
029import microsoft.exchange.webservices.data.core.XmlElementNames;
030import microsoft.exchange.webservices.data.core.enumeration.misc.IdFormat;
031import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException;
032
033/**
034 * Represents the Id of a public folder expressed in a specific format.
035 */
036public class AlternatePublicFolderId extends AlternateIdBase {
037
038  /**
039   * Name of schema type used for AlternatePublicFolderId element.
040   */
041  public final static String SchemaTypeName =
042      "AlternatePublicFolderIdType";
043
044  private String folderId;
045
046  /**
047   * Initializes a new instance of AlternatePublicFolderId.
048   */
049  public AlternatePublicFolderId() {
050    super();
051  }
052
053  /**
054   * Initializes a new instance of AlternatePublicFolderId.
055   *
056   * @param format   the format
057   * @param folderId the folder id
058   */
059  public AlternatePublicFolderId(IdFormat format, String folderId) {
060    super(format);
061    this.setFolderId(folderId);
062  }
063
064  /**
065   * The Id of the public folder.
066   *
067   * @return the folder id
068   */
069  public String getFolderId() {
070    return this.folderId;
071
072  }
073
074  /**
075   * Sets the folder id.
076   *
077   * @param folderId the new folder id
078   */
079  public void setFolderId(String folderId) {
080    this.folderId = folderId;
081  }
082
083  /**
084   * Gets the name of the XML element.
085   *
086   * @return XML element name
087   */
088  @Override
089  protected String getXmlElementName() {
090    return XmlElementNames.AlternatePublicFolderId;
091  }
092
093  /**
094   * Writes the attribute to XML.
095   *
096   * @param writer the writer
097   * @throws ServiceXmlSerializationException the service xml serialization exception
098   */
099  @Override
100  protected void writeAttributesToXml(EwsServiceXmlWriter writer)
101      throws ServiceXmlSerializationException {
102    super.writeAttributesToXml(writer);
103    writer.writeAttributeValue(XmlAttributeNames.FolderId, this
104        .getFolderId());
105  }
106
107  /**
108   * Loads the attribute from XML.
109   *
110   * @param reader the reader
111   * @throws Exception the exception
112   */
113  @Override public void loadAttributesFromXml(EwsServiceXmlReader reader)
114      throws Exception {
115    super.loadAttributesFromXml(reader);
116    this.setFolderId(reader.readAttributeValue(XmlAttributeNames.FolderId));
117  }
118
119}