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.search;
025
026 import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter;
027 import microsoft.exchange.webservices.data.core.XmlElementNames;
028 import microsoft.exchange.webservices.data.core.request.ServiceRequestBase;
029 import microsoft.exchange.webservices.data.core.enumeration.search.OffsetBasePoint;
030 import microsoft.exchange.webservices.data.core.enumeration.service.ServiceObjectType;
031 import microsoft.exchange.webservices.data.core.enumeration.misc.XmlNamespace;
032 import microsoft.exchange.webservices.data.core.exception.service.local.ServiceValidationException;
033 import microsoft.exchange.webservices.data.core.exception.service.local.ServiceVersionException;
034 import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException;
035
036 import javax.xml.stream.XMLStreamException;
037
038 /**
039 * Represents the view settings in a folder search operation.
040 */
041 public final class ConversationIndexedItemView extends PagedView {
042
043 private OrderByCollection orderBy = new OrderByCollection();
044
045
046 /**
047 * Gets the type of service object this view applies to.
048 *
049 * @return A ServiceObjectType value.
050 */
051 @Override
052 protected ServiceObjectType getServiceObjectType() {
053 return ServiceObjectType.Conversation;
054 }
055
056 /**
057 * Writes the attribute to XML.
058 *
059 * @param writer The writer.
060 */
061 @Override public void writeAttributesToXml(EwsServiceXmlWriter writer) {
062 // Do nothing
063 }
064
065 /**
066 * Gets the name of the view XML element.
067 *
068 * @return XML element name.
069 */
070 @Override
071 protected String getViewXmlElementName() {
072 return XmlElementNames.IndexedPageItemView;
073 }
074
075 /**
076 * Validates this view.
077 *
078 * @param request The request using this view.
079 */
080 @Override public void internalValidate(ServiceRequestBase request)
081 throws ServiceVersionException, ServiceValidationException {
082 super.internalValidate(request);
083 }
084
085 /**
086 * Internals the write search settings to XML.
087 *
088 * @param writer The writer.
089 * @param groupBy The group by.
090 */
091 @Override
092 protected void internalWriteSearchSettingsToXml(EwsServiceXmlWriter writer,
093 Grouping groupBy) throws ServiceXmlSerializationException,
094 XMLStreamException {
095 super.internalWriteSearchSettingsToXml(writer, groupBy);
096 }
097
098 /**
099 * Writes OrderBy property to XML.
100 *
101 * @param writer The writer
102 */
103 @Override public void writeOrderByToXml(EwsServiceXmlWriter writer)
104 throws ServiceXmlSerializationException, XMLStreamException {
105 this.orderBy.writeToXml(writer, XmlElementNames.SortOrder);
106 }
107
108 /**
109 * Writes to XML.
110 *
111 * @param writer The writer
112 */
113 public void writeToXml(EwsServiceXmlWriter writer) throws Exception {
114 writer.writeStartElement(XmlNamespace.Messages,
115 this.getViewXmlElementName());
116
117 this.internalWriteViewToXml(writer);
118
119 writer.writeEndElement(); // this.GetViewXmlElementName()
120 }
121
122 /**
123 * Initializes a new instance of the <see cref="ItemView"/> class.
124 *
125 * @param pageSize The maximum number of elements the search operation should return.
126 */
127 public ConversationIndexedItemView(int pageSize) {
128 super(pageSize);
129 }
130
131 /**
132 * Initializes a new instance of the ItemView class.
133 *
134 * @param pageSize The maximum number of elements the search operation should return.
135 * @param offset The offset of the view from the base point.
136 */
137 public ConversationIndexedItemView(int pageSize, int offset) {
138 super(pageSize, offset);
139 this.setOffset(offset);
140 }
141
142 /**
143 * Initializes a new instance of the ItemView class.
144 *
145 * @param pageSize The maximum number of elements the search operation should return.
146 * @param offset The offset of the view from the base point.
147 * @param offsetBasePoint The base point of the offset.
148 */
149 public ConversationIndexedItemView(
150 int pageSize,
151 int offset,
152 OffsetBasePoint offsetBasePoint) {
153 super(pageSize, offset, offsetBasePoint);
154
155 }
156
157 /**
158 * Gets the property against which the returned item should be ordered.
159 */
160 public OrderByCollection getOrderBy() {
161 return this.orderBy;
162 }
163 }