All Downloads are FREE. Search and download functionalities are using the official Maven repository.

microsoft.exchange.webservices.data.Suggestion Maven / Gradle / Ivy

Go to download

The source came from http://archive.msdn.microsoft.com/ewsjavaapi Support for Maven has been added.

The newest version!
/**************************************************************************
 * copyright file="Suggestion.java" company="Microsoft"
 *     Copyright (c) Microsoft Corporation.  All rights reserved.
 * 
 * Defines the Suggestion.java.
 **************************************************************************/
package microsoft.exchange.webservices.data;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;

import javax.xml.stream.XMLStreamException;

/**
 * Represents a suggestion for a specific date.
 * 
 */
public final class Suggestion extends ComplexProperty {

	/** The date. */
	private Date date;

	/** The quality. */
	private SuggestionQuality quality;

	/** The time suggestions. */
	private Collection timeSuggestions = 
		new ArrayList();

	/**
	 * Initializes a new instance of the Suggestion class.
	 */
	protected Suggestion() {
		super();
	}

	/**
	 * Tries to read element from XML.
	 * 
	 * @param reader
	 *            the reader
	 * @return True if appropriate element was read.
	 * @throws XMLStreamException
	 *             the xML stream exception
	 * @throws ServiceXmlDeserializationException
	 *             the service xml deserialization exception
	 * @throws Exception
	 *             the exception
	 */
	@Override
	protected boolean tryReadElementFromXml(EwsServiceXmlReader reader)
			throws XMLStreamException, ServiceXmlDeserializationException,
			Exception {
		if (reader.getLocalName().equals(XmlElementNames.Date)) {
			SimpleDateFormat sdfin = new SimpleDateFormat(
					"yyyy-MM-dd'T'HH:mm:ss");
			Date tempDate = sdfin.parse(reader.readElementValue());
			this.date = tempDate;
			return true;
		} else if (reader.getLocalName().equals(XmlElementNames.DayQuality)) {
			this.quality = reader.readElementValue(SuggestionQuality.class);
			return true;
		} else if (reader.getLocalName()
				.equals(XmlElementNames.SuggestionArray)) {
			if (!reader.isEmptyElement()) {
				do {
					reader.read();

					if (reader.isStartElement(XmlNamespace.Types,
							XmlElementNames.Suggestion)) {
						TimeSuggestion timeSuggestion = new TimeSuggestion();

						timeSuggestion.loadFromXml(reader, reader
								.getLocalName());

						this.timeSuggestions.add(timeSuggestion);
					}
				} while (!reader.isEndElement(XmlNamespace.Types,
						XmlElementNames.SuggestionArray));
			}

			return true;
		} else {
			return false;
		}

	}

	/**
	 * Gets the date and time of the suggestion.
	 * 
	 * @return the date
	 */
	public Date getDate() {
		return date;
	}

	/**
	 * Gets the quality of the suggestion.
	 * 
	 * @return the quality
	 */
	public SuggestionQuality getQuality() {
		return quality;
	}

	/**
	 * Gets a collection of suggested times within the suggested day.
	 * 
	 * @return the time suggestions
	 */
	public Collection getTimeSuggestions() {
		return timeSuggestions;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy