EWS: implement SortOrder

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2092 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2013-04-23 08:31:19 +00:00
parent f9715c60c4
commit 3f79bba608
2 changed files with 61 additions and 0 deletions

View File

@ -82,6 +82,7 @@ public abstract class EWSMethod extends PostMethod {
protected Item item;
protected SearchExpression searchExpression;
protected FieldOrder fieldOrder;
protected String serverVersion;
protected String timezoneContext;
@ -163,6 +164,10 @@ public abstract class EWSMethod extends PostMethod {
this.searchExpression = searchExpression;
}
protected void setFieldOrder(FieldOrder fieldOrder) {
this.fieldOrder = fieldOrder;
}
protected void writeShape(Writer writer) throws IOException {
if (baseShape != null) {
writer.write("<m:");
@ -277,6 +282,16 @@ public abstract class EWSMethod extends PostMethod {
}
}
protected void writeSortOrder(Writer writer) throws IOException {
if (fieldOrder != null) {
writer.write("<m:SortOrder>");
StringBuilder buffer = new StringBuilder();
fieldOrder.appendTo(buffer);
writer.write(buffer.toString());
writer.write("</m:SortOrder>");
}
}
protected void startChanges(Writer writer) throws IOException {
//noinspection VariableNotUsedInsideIf
if (updates != null) {
@ -371,6 +386,7 @@ public abstract class EWSMethod extends PostMethod {
writeShape(writer);
writeIndexedPageItemView(writer);
writeRestriction(writer);
writeSortOrder(writer);
writeParentFolderId(writer);
writeToFolderId(writer);
writeItemId(writer);

View File

@ -0,0 +1,45 @@
/*
* DavMail POP/IMAP/SMTP/CalDav/LDAP Exchange Gateway
* Copyright (C) 2013 Mickael Guessant
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package davmail.exchange.ews;
/**
* Sort order.
*/
public class FieldOrder {
protected enum Order {
Descending, Ascending
}
protected Order order;
protected FieldURI fieldURI;
public FieldOrder(FieldURI fieldURI, Order order) {
this.fieldURI = fieldURI;
this.order = order;
}
/**
* Append sort order to buffer.
*
* @param buffer search buffer
*/
void appendTo(StringBuilder buffer) {
buffer.append("<t:FieldOrder Order=\"").append(order).append("\">");
fieldURI.appendTo(buffer);
buffer.append("</t:FieldOrder>");
}
}