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.property.definition;
025
026 import microsoft.exchange.webservices.data.core.EwsServiceXmlWriter;
027 import microsoft.exchange.webservices.data.core.XmlAttributeNames;
028 import microsoft.exchange.webservices.data.core.XmlElementNames;
029 import microsoft.exchange.webservices.data.core.exception.service.local.ServiceXmlSerializationException;
030
031 /**
032 * Represents the definition of the GroupMember property.
033 */
034 public final class GroupMemberPropertyDefinition extends
035 ServiceObjectPropertyDefinition {
036
037 // / FieldUri of IndexedFieldURI for a group member.
038 /**
039 * The Constant FIELDURI.
040 */
041 private final static String FIELDURI = "distributionlist:Members:Member";
042
043 // / Member key.
044 // / Maps to the Index attribute of IndexedFieldURI element.
045 /**
046 * The key.
047 */
048 private String key;
049
050 /**
051 * Initializes a new instance of the GroupMemberPropertyDefinition class.
052 *
053 * @param key the key
054 */
055 public GroupMemberPropertyDefinition(String key) {
056 super(FIELDURI);
057 this.key = key;
058 }
059
060 /**
061 * Initializes a new instance of the GroupMemberPropertyDefinition class
062 * without key.
063 */
064 public GroupMemberPropertyDefinition() {
065 super(FIELDURI);
066 }
067
068 /**
069 * Gets the key.
070 *
071 * @return the key
072 */
073 public String getKey() {
074 return key;
075 }
076
077 /**
078 * Sets the key.
079 *
080 * @param key the new key
081 */
082 public void setKey(String key) {
083 this.key = key;
084 }
085
086 /**
087 * Gets the name of the XML element.
088 *
089 * @return XML element name.
090 */
091 protected String getXmlElementName() {
092 return XmlElementNames.IndexedFieldURI;
093 }
094
095 /**
096 * Writes the attribute to XML.
097 *
098 * @param writer the writer
099 * @throws ServiceXmlSerializationException the service xml serialization exception
100 */
101 protected void writeAttributesToXml(EwsServiceXmlWriter writer)
102 throws ServiceXmlSerializationException {
103 super.writeAttributesToXml(writer);
104 writer.writeAttributeValue(XmlAttributeNames.FieldIndex, this.key);
105 }
106
107 /**
108 * Gets the property definition's printable name.
109 *
110 * @return The property definition's printable name.
111 */
112 @Override public String getPrintableName() {
113 return String.format("%s:%s", FIELDURI, this.key);
114 }
115
116
117 /**
118 * Gets the property type.
119 */
120 @Override
121 public Class<String> getType() {
122 return String.class;
123 }
124
125
126 }