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.property.complex;
025
026import microsoft.exchange.webservices.data.core.EwsServiceXmlReader;
027import microsoft.exchange.webservices.data.core.XmlElementNames;
028
029import java.util.Date;
030
031/**
032 * Encapsulates information on the occurrence of a recurring appointment.
033 */
034public final class OccurrenceInfo extends ComplexProperty {
035
036  /**
037   * The item id.
038   */
039  private ItemId itemId;
040
041  /**
042   * The start.
043   */
044  private Date start;
045
046  /**
047   * The end.
048   */
049  private Date end;
050
051  /**
052   * The original start.
053   */
054  private Date originalStart;
055
056  /**
057   * Initializes a new instance of the OccurrenceInfo class.
058   */
059  public OccurrenceInfo() {
060  }
061
062  /**
063   * Tries to read element from XML.
064   *
065   * @param reader the reader
066   * @return true, if successful
067   * @throws Exception the exception
068   */
069  public boolean tryReadElementFromXml(EwsServiceXmlReader reader)
070      throws Exception {
071    if (reader.getLocalName().equals(XmlElementNames.ItemId)) {
072
073      this.itemId = new ItemId();
074      this.itemId.loadFromXml(reader, reader.getLocalName());
075      return true;
076    } else if (reader.getLocalName().equals(XmlElementNames.Start)) {
077
078      this.start = reader.readElementValueAsDateTime();
079      return true;
080    } else if (reader.getLocalName().equals(XmlElementNames.End)) {
081
082      this.end = reader.readElementValueAsDateTime();
083      return true;
084    } else if (reader.getLocalName().equals(XmlElementNames.OriginalStart)) {
085
086      this.originalStart = reader.readElementValueAsDateTime();
087      return true;
088    } else {
089
090      return false;
091    }
092  }
093
094  /**
095   * Gets the Id of the occurrence.
096   *
097   * @return the item id
098   */
099  public ItemId getItemId() {
100    return itemId;
101  }
102
103  /**
104   * Gets the start date and time of the occurrence.
105   *
106   * @return the start
107   */
108  public Date getStart() {
109    return start;
110  }
111
112  /**
113   * Gets the end date and time of the occurrence.
114   *
115   * @return the end
116   */
117  public Date getEnd() {
118    return end;
119  }
120
121  /**
122   * Gets the original start date and time of the occurrence.
123   *
124   * @return the original start
125   */
126  public Date getOriginalStart() {
127    return originalStart;
128  }
129
130}