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.search; 025 026import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter; 027import microsoft.exchange.webservices.data.core.XmlAttributeNames; 028import microsoft.exchange.webservices.data.core.XmlElementNames; 029import microsoft.exchange.webservices.data.core.enumeration.search.FolderTraversal; 030import microsoft.exchange.webservices.data.core.enumeration.search.OffsetBasePoint; 031import microsoft.exchange.webservices.data.core.enumeration.service.ServiceObjectType; 032import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException; 033import org.apache.commons.logging.Log; 034import org.apache.commons.logging.LogFactory; 035 036/** 037 * Represents the view settings in a folder search operation. 038 */ 039public final class FolderView extends PagedView { 040 041 private static final Log LOG = LogFactory.getLog(FolderView.class); 042 043 /** 044 * The traversal. 045 */ 046 private FolderTraversal traversal = FolderTraversal.Shallow; 047 048 /** 049 * Gets the name of the view XML element. 050 * 051 * @return Xml Element name 052 */ 053 @Override 054 protected String getViewXmlElementName() { 055 return XmlElementNames.IndexedPageFolderView; 056 } 057 058 /** 059 * Gets the type of service object this view applies to. 060 * 061 * @return A ServiceObjectType value. 062 */ 063 @Override 064 protected ServiceObjectType getServiceObjectType() { 065 return ServiceObjectType.Folder; 066 } 067 068 /** 069 * Writes the attribute to XML. 070 * 071 * @param writer The writer 072 */ 073 @Override public void writeAttributesToXml(EwsServiceXmlWriter writer) { 074 try { 075 writer.writeAttributeValue(XmlAttributeNames.Traversal, this 076 .getTraversal()); 077 } catch (ServiceXmlSerializationException e) { 078 LOG.error(e); 079 } 080 } 081 082 /** 083 * Initializes a new instance of the FolderView class. 084 * 085 * @param pageSize The maximum number of elements the search operation should 086 * return. 087 */ 088 public FolderView(int pageSize) { 089 super(pageSize); 090 } 091 092 /** 093 * Initializes a new instance of the FolderView class. 094 * 095 * @param pageSize The maximum number of elements the search operation should 096 * return. 097 * @param offset The offset of the view from the base point. 098 */ 099 public FolderView(int pageSize, int offset) { 100 super(pageSize, offset); 101 } 102 103 /** 104 * Initializes a new instance of the FolderView class. 105 * 106 * @param pageSize The maximum number of elements the search operation should 107 * return. 108 * @param offset The offset of the view from the base point. 109 * @param offsetBasePoint The base point of the offset. 110 */ 111 public FolderView(int pageSize, int offset, 112 OffsetBasePoint offsetBasePoint) { 113 super(pageSize, offset, offsetBasePoint); 114 } 115 116 /** 117 * Gets the search traversal mode. Defaults to FolderTraversal.Shallow. 118 * 119 * @return the traversal 120 */ 121 public FolderTraversal getTraversal() { 122 return traversal; 123 } 124 125 /** 126 * Sets the search traversal mode. Defaults to FolderTraversal.Shallow. 127 * 128 * @param traversal the new traversal 129 */ 130 public void setTraversal(FolderTraversal traversal) { 131 this.traversal = traversal; 132 } 133}