001package biweekly.property; 002 003import java.util.List; 004 005import biweekly.component.VAlarm; 006import biweekly.parameter.CalendarUserType; 007import biweekly.parameter.ParticipationStatus; 008import biweekly.parameter.Role; 009 010/* 011 Copyright (c) 2013, Michael Angstadt 012 All rights reserved. 013 014 Redistribution and use in source and binary forms, with or without 015 modification, are permitted provided that the following conditions are met: 016 017 1. Redistributions of source code must retain the above copyright notice, this 018 list of conditions and the following disclaimer. 019 2. Redistributions in binary form must reproduce the above copyright notice, 020 this list of conditions and the following disclaimer in the documentation 021 and/or other materials provided with the distribution. 022 023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 024 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 025 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 026 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 027 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 028 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 029 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 030 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 031 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 032 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 033 */ 034 035/** 036 * <p> 037 * Defines an attendee (such as a person attending an event). This property has 038 * different meanings depending on the component that it belongs to: 039 * <ul> 040 * <li>{@link VAlarm} (with "EMAIL" action) - An email address that is to 041 * receive the alarm.</li> 042 * <li>All others - An attendee of the event.</li> 043 * </ul> 044 * </p> 045 * 046 * <p> 047 * <b>Code sample:</b> 048 * 049 * <pre class="brush:java"> 050 * VEvent event = new VEvent(); 051 * 052 * Attendee attendee = Attendee.email("johndoe@example.com") 053 * attendee.setCommonName("John Doe"); 054 * attendee.setRsvp(true); 055 * attendee.setRole(Role.CHAIR); 056 * attendee.setParticipationStatus(ParticipationStatus.ACCEPTED); 057 * event.addAttendee(attendee); 058 * </pre> 059 * 060 * </p> 061 * @author Michael Angstadt 062 * @see <a href="http://tools.ietf.org/html/rfc5545#page-107">RFC 5545 p.107-9</a> 063 */ 064public class Attendee extends TextProperty { 065 /** 066 * Creates an attendee property. 067 * @param uri a URI representing the attendee (typically, an email address, 068 * e.g. "mailto:johndoe@example.com") 069 */ 070 public Attendee(String uri) { 071 super(uri); 072 } 073 074 /** 075 * Creates an attendee property using an email address as its value. 076 * @param email the email address (e.g. "johndoe@example.com") 077 * @return the property 078 */ 079 public static Attendee email(String email) { 080 return new Attendee("mailto:" + email); 081 } 082 083 /** 084 * Gets the type of user the attendee is (for example, an "individual" or a 085 * "room"). 086 * @return the calendar user type or null if not set 087 * @see <a href="http://tools.ietf.org/html/rfc5545#page-16">RFC 5545 p.16</a> 088 */ 089 public CalendarUserType getCalendarUserType() { 090 return parameters.getCalendarUserType(); 091 } 092 093 /** 094 * Sets the type of user the attendee is (for example, an "individual" or a 095 * "room"). 096 * @param cutype the calendar user type or null to remove 097 * @see <a href="http://tools.ietf.org/html/rfc5545#page-16">RFC 5545 p.16</a> 098 */ 099 public void setCalendarUserType(CalendarUserType cutype) { 100 parameters.setCalendarUserType(cutype); 101 } 102 103 /** 104 * Gets the groups that the attendee is a member of. 105 * @return the group URIs (typically, these are email address URIs, e.g. 106 * "mailto:mailinglist@example.com") 107 * @see <a href="http://tools.ietf.org/html/rfc5545#page-21">RFC 5545 p.21-2</a> 108 */ 109 public List<String> getMembers() { 110 return parameters.getMembers(); 111 } 112 113 /** 114 * Adds a group that the attendee is a member of. 115 * @param uri the group URI (typically, an email address URI, e.g. 116 * "mailto:mailinglist@example.com") 117 * @see <a href="http://tools.ietf.org/html/rfc5545#page-21">RFC 5545 p.21-2</a> 118 */ 119 public void addMember(String uri) { 120 parameters.addMember(uri); 121 } 122 123 /** 124 * Gets the attendee's role (for example, "chair" or 125 * "required participant"). 126 * @return the role or null if not set 127 * @see <a href="http://tools.ietf.org/html/rfc5545#page-25">RFC 5545 p.25-6</a> 128 */ 129 public Role getRole() { 130 return parameters.getRole(); 131 } 132 133 /** 134 * Sets the attendee's role (for example, "chair" or 135 * "required participant"). 136 * @param role the role or null to remove 137 * @see <a href="http://tools.ietf.org/html/rfc5545#page-25">RFC 5545 p.25-6</a> 138 */ 139 public void setRole(Role role) { 140 parameters.setRole(role); 141 } 142 143 /** 144 * Gets the attendee's level of participation. 145 * @return the participation status or null if not set 146 * @see <a href="http://tools.ietf.org/html/rfc5545#page-22">RFC 5545 p.22-3</a> 147 */ 148 public ParticipationStatus getParticipationStatus() { 149 return parameters.getParticipationStatus(); 150 } 151 152 /** 153 * Sets the attendee's level of participation. 154 * @param status the participation status or null to remove 155 * @see <a href="http://tools.ietf.org/html/rfc5545#page-22">RFC 5545 p.22-3</a> 156 */ 157 public void setParticipationStatus(ParticipationStatus status) { 158 parameters.setParticipationStatus(status); 159 } 160 161 /** 162 * Gets whether the organizer requests a response from the attendee. 163 * @return true if an RSVP is requested, false if not, null if not set 164 * @see <a href="http://tools.ietf.org/html/rfc5545#page-26">RFC 5545 p.26-7</a> 165 */ 166 public Boolean getRsvp() { 167 return parameters.getRsvp(); 168 } 169 170 /** 171 * Sets whether the organizer requests a response from the attendee. 172 * @param rsvp true if an RSVP has been requested, false if not, null to 173 * remove 174 * @see <a href="http://tools.ietf.org/html/rfc5545#page-26">RFC 5545 p.26-7</a> 175 */ 176 public void setRsvp(Boolean rsvp) { 177 parameters.setRsvp(rsvp); 178 } 179 180 /** 181 * Gets the people who have delegated their responsibility to the attendee. 182 * @return the delegators (typically email URIs, e.g. 183 * "mailto:janedoe@example.com") 184 * @see <a href="http://tools.ietf.org/html/rfc5545#page-17">RFC 5545 p.17</a> 185 */ 186 public List<String> getDelegatedFrom() { 187 return parameters.getDelegatedFrom(); 188 } 189 190 /** 191 * Adds a person who has delegated his or her responsibility to the 192 * attendee. 193 * @param uri the delegator (typically an email URI, e.g. 194 * "mailto:janedoe@example.com") 195 * @see <a href="http://tools.ietf.org/html/rfc5545#page-17">RFC 5545 p.17</a> 196 */ 197 public void addDelegatedFrom(String uri) { 198 parameters.addDelegatedFrom(uri); 199 } 200 201 /** 202 * Gets the people to which the attendee has delegated his or her 203 * responsibility. 204 * @return the delegatees (typically email URIs, e.g. 205 * "mailto:janedoe@example.com") 206 * @see <a href="http://tools.ietf.org/html/rfc5545#page-17">RFC 5545 p.17-8</a> 207 */ 208 public List<String> getDelegatedTo() { 209 return parameters.getDelegatedTo(); 210 } 211 212 /** 213 * Adds a person to which the attendee has delegated his or her 214 * responsibility. 215 * @param uri the delegatee (typically an email URI, e.g. 216 * "mailto:janedoe@example.com") 217 * @see <a href="http://tools.ietf.org/html/rfc5545#page-17">RFC 5545 p.17-8</a> 218 */ 219 public void addDelegatedTo(String uri) { 220 parameters.addDelegatedTo(uri); 221 } 222 223 @Override 224 public String getSentBy() { 225 return super.getSentBy(); 226 } 227 228 @Override 229 public void setSentBy(String uri) { 230 super.setSentBy(uri); 231 } 232 233 @Override 234 public String getCommonName() { 235 return super.getCommonName(); 236 } 237 238 @Override 239 public void setCommonName(String commonName) { 240 super.setCommonName(commonName); 241 } 242 243 @Override 244 public String getDirectoryEntry() { 245 return super.getDirectoryEntry(); 246 } 247 248 @Override 249 public void setDirectoryEntry(String uri) { 250 super.setDirectoryEntry(uri); 251 } 252 253 /** 254 * Gets the language that the common name parameter is written in. 255 */ 256 @Override 257 public String getLanguage() { 258 return super.getLanguage(); 259 } 260 261 /** 262 * Sets the language that the common name parameter is written in. 263 */ 264 @Override 265 public void setLanguage(String language) { 266 super.setLanguage(language); 267 } 268 269}