001package biweekly.property; 002 003import java.util.List; 004 005import biweekly.ICalVersion; 006import biweekly.Warning; 007import biweekly.component.ICalComponent; 008import biweekly.component.VAlarm; 009import biweekly.parameter.CalendarUserType; 010import biweekly.parameter.ParticipationLevel; 011import biweekly.parameter.ParticipationStatus; 012import biweekly.parameter.Role; 013 014/* 015 Copyright (c) 2013-2015, Michael Angstadt 016 All rights reserved. 017 018 Redistribution and use in source and binary forms, with or without 019 modification, are permitted provided that the following conditions are met: 020 021 1. Redistributions of source code must retain the above copyright notice, this 022 list of conditions and the following disclaimer. 023 2. Redistributions in binary form must reproduce the above copyright notice, 024 this list of conditions and the following disclaimer in the documentation 025 and/or other materials provided with the distribution. 026 027 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 028 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 029 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 030 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 031 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 032 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 033 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 034 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 035 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 036 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 037 */ 038 039/** 040 * <p> 041 * Defines an attendee (such as a person attending an event). This property has 042 * different meanings depending on the component that it belongs to: 043 * <ul> 044 * <li>{@link VAlarm} (with "EMAIL" action) - An email address that is to 045 * receive the alarm.</li> 046 * <li>All others - An attendee of the calendar entity.</li> 047 * </ul> 048 * </p> 049 * 050 * <p> 051 * <b>Code sample:</b> 052 * 053 * <pre class="brush:java"> 054 * VEvent event = new VEvent(); 055 * 056 * Attendee attendee = Attendee.email("johndoe@example.com") 057 * attendee.setCommonName("John Doe"); 058 * attendee.setRsvp(true); 059 * attendee.setRole(Role.CHAIR); 060 * attendee.setParticipationStatus(ParticipationStatus.ACCEPTED); 061 * event.addAttendee(attendee); 062 * </pre> 063 * 064 * </p> 065 * @author Michael Angstadt 066 * @see <a href="http://tools.ietf.org/html/rfc5545#page-107">RFC 5545 067 * p.107-9</a> 068 * @see <a href="http://tools.ietf.org/html/rfc2445#page-102">RFC 2445 069 * p.102-4</a> 070 * @see <a href="http://www.imc.org/pdi/vcal-10.doc">vCal 1.0 p.25-7</a> 071 */ 072public class Attendee extends ICalProperty { 073 private String name, email, uri; 074 private Role role; 075 private ParticipationLevel participationLevel; 076 private ParticipationStatus status; 077 private Boolean rsvp; 078 079 /** 080 * Creates an attendee property. 081 * @param name the attendee's name (e.g. "John Doe") 082 * @param email the attendee's email (e.g. "jdoe@example.com") 083 */ 084 public Attendee(String name, String email) { 085 this.name = name; 086 this.email = email; 087 } 088 089 /** 090 * Creates an attendee property. 091 * @param uri a URI representing the attendee (typically, an email address, 092 * e.g. "mailto:johndoe@example.com") 093 */ 094 public Attendee(String uri) { 095 this.uri = uri; 096 } 097 098 /** 099 * Gets the attendee's email 100 * @return the email (e.g. "jdoe@company.com") 101 */ 102 public String getEmail() { 103 return email; 104 } 105 106 /** 107 * Sets the attendee's email 108 * @param email the email (e.g. "jdoe@company.com") 109 */ 110 public void setEmail(String email) { 111 this.email = email; 112 } 113 114 /** 115 * Gets a URI representing the attendee. 116 * @return the URI (e.g. "mailto:jdoe@company.com") 117 */ 118 public String getUri() { 119 return uri; 120 } 121 122 /** 123 * Sets a URI representing the attendee. 124 * @param uri the URI (e.g. "mailto:jdoe@company.com") 125 */ 126 public void setUri(String uri) { 127 this.uri = uri; 128 } 129 130 /** 131 * <p> 132 * Gets the type of user the attendee is (for example, an "individual" or a 133 * "room"). 134 * </p> 135 * <p> 136 * <b>Supported versions:</b> {@code 2.0} 137 * </p> 138 * @return the calendar user type or null if not set 139 * @see <a href="http://tools.ietf.org/html/rfc5545#page-16">RFC 5545 140 * p.16</a> 141 */ 142 public CalendarUserType getCalendarUserType() { 143 return parameters.getCalendarUserType(); 144 } 145 146 /** 147 * <p> 148 * Sets the type of user the attendee is (for example, an "individual" or a 149 * "room"). 150 * </p> 151 * <p> 152 * <b>Supported versions:</b> {@code 2.0} 153 * </p> 154 * @param cutype the calendar user type or null to remove 155 * @see <a href="http://tools.ietf.org/html/rfc5545#page-16">RFC 5545 156 * p.16</a> 157 */ 158 public void setCalendarUserType(CalendarUserType cutype) { 159 parameters.setCalendarUserType(cutype); 160 } 161 162 /** 163 * <p> 164 * Gets the groups that the attendee is a member of. 165 * </p> 166 * <p> 167 * <b>Supported versions:</b> {@code 2.0} 168 * </p> 169 * @return the group URIs (typically, these are email address URIs, e.g. 170 * "mailto:mailinglist@example.com") 171 * @see <a href="http://tools.ietf.org/html/rfc5545#page-21">RFC 5545 172 * p.21-2</a> 173 */ 174 public List<String> getMembers() { 175 return parameters.getMembers(); 176 } 177 178 /** 179 * <p> 180 * Adds a group that the attendee is a member of. 181 * </p> 182 * <p> 183 * <b>Supported versions:</b> {@code 2.0} 184 * </p> 185 * @param uri the group URI (typically, an email address URI, e.g. 186 * "mailto:mailinglist@example.com") 187 * @see <a href="http://tools.ietf.org/html/rfc5545#page-21">RFC 5545 188 * p.21-2</a> 189 */ 190 public void addMember(String uri) { 191 parameters.addMember(uri); 192 } 193 194 /** 195 * Gets an attendee's role (for example, "chair" or "attendee"). 196 * @return the role or null if not set 197 * @see <a href="http://tools.ietf.org/html/rfc5545#page-25">RFC 5545 198 * p.25-6</a> 199 * @see <a href="http://www.imc.org/pdi/vcal-10.doc">vCal 1.0 p.25</a> 200 */ 201 public Role getRole() { 202 return role; 203 } 204 205 /** 206 * Sets an attendee's role (for example, "chair" or "attendee"). 207 * @param role the role or null to remove 208 * @see <a href="http://tools.ietf.org/html/rfc5545#page-25">RFC 5545 209 * p.25-6</a> 210 * @see <a href="http://www.imc.org/pdi/vcal-10.doc">vCal 1.0 p.25</a> 211 */ 212 public void setRole(Role role) { 213 this.role = role; 214 } 215 216 /** 217 * Gets an attendee's level of participation. 218 * @return the participation level or null if not set 219 * @see <a href="http://tools.ietf.org/html/rfc5545#page-25">RFC 5545 220 * p.25-6</a> 221 * @see <a href="http://www.imc.org/pdi/vcal-10.doc">vCal 1.0 p.26-7</a> 222 */ 223 public ParticipationLevel getParticipationLevel() { 224 return participationLevel; 225 } 226 227 /** 228 * Sets an attendee's level of participation. 229 * @param level the participation level or null to remove 230 * @see <a href="http://tools.ietf.org/html/rfc5545#page-25">RFC 5545 231 * p.25-6</a> 232 * @see <a href="http://www.imc.org/pdi/vcal-10.doc">vCal 1.0 p.26-7</a> 233 */ 234 public void setParticipationLevel(ParticipationLevel level) { 235 this.participationLevel = level; 236 } 237 238 /** 239 * Gets an attendee's participation status 240 * @return the participation status or null if not set 241 * @see <a href="http://tools.ietf.org/html/rfc5545#page-22">RFC 5545 242 * p.22-3</a> 243 * @see <a href="http://www.imc.org/pdi/vcal-10.doc">vCal 1.0 p.25-6</a> 244 */ 245 public ParticipationStatus getParticipationStatus() { 246 return status; 247 } 248 249 /** 250 * Sets an attendee's participation status. 251 * @param status the participation status or null to remove 252 * @see <a href="http://tools.ietf.org/html/rfc5545#page-22">RFC 5545 253 * p.22-3</a> 254 * @see <a href="http://www.imc.org/pdi/vcal-10.doc">vCal 1.0 p.25-6</a> 255 */ 256 public void setParticipationStatus(ParticipationStatus status) { 257 this.status = status; 258 } 259 260 /** 261 * Gets whether the organizer requests a response from the attendee. 262 * @return true if an RSVP is requested, false if not, null if not set 263 * @see <a href="http://tools.ietf.org/html/rfc5545#page-26">RFC 5545 264 * p.26-7</a> 265 */ 266 public Boolean getRsvp() { 267 return rsvp; 268 } 269 270 /** 271 * Sets whether the organizer requests a response from the attendee. 272 * @param rsvp true if an RSVP has been requested, false if not, null to 273 * remove 274 * @see <a href="http://tools.ietf.org/html/rfc5545#page-26">RFC 5545 275 * p.26-7</a> 276 */ 277 public void setRsvp(Boolean rsvp) { 278 this.rsvp = rsvp; 279 } 280 281 /** 282 * <p> 283 * Gets the people who have delegated their responsibility to the attendee. 284 * @return the delegators (typically email URIs, e.g. 285 * "mailto:janedoe@example.com") 286 * </p> 287 * <p> 288 * <b>Supported versions:</b> {@code 2.0} 289 * </p> 290 * @see <a href="http://tools.ietf.org/html/rfc5545#page-17">RFC 5545 291 * p.17</a> 292 */ 293 public List<String> getDelegatedFrom() { 294 return parameters.getDelegatedFrom(); 295 } 296 297 /** 298 * <p> 299 * Adds a person who has delegated his or her responsibility to the 300 * attendee. 301 * </p> 302 * <p> 303 * <b>Supported versions:</b> {@code 2.0} 304 * </p> 305 * @param uri the delegator (typically an email URI, e.g. 306 * "mailto:janedoe@example.com") 307 * @see <a href="http://tools.ietf.org/html/rfc5545#page-17">RFC 5545 308 * p.17</a> 309 */ 310 public void addDelegatedFrom(String uri) { 311 parameters.addDelegatedFrom(uri); 312 } 313 314 /** 315 * <p> 316 * Gets the people to which the attendee has delegated his or her 317 * responsibility. 318 * </p> 319 * <p> 320 * <b>Supported versions:</b> {@code 2.0} 321 * </p> 322 * @return the delegatees (typically email URIs, e.g. 323 * "mailto:janedoe@example.com") 324 * @see <a href="http://tools.ietf.org/html/rfc5545#page-17">RFC 5545 325 * p.17-8</a> 326 */ 327 public List<String> getDelegatedTo() { 328 return parameters.getDelegatedTo(); 329 } 330 331 /** 332 * <p> 333 * Adds a person to which the attendee has delegated his or her 334 * responsibility. 335 * </p> 336 * <p> 337 * <b>Supported versions:</b> {@code 2.0} 338 * </p> 339 * @param uri the delegatee (typically an email URI, e.g. 340 * "mailto:janedoe@example.com") 341 * @see <a href="http://tools.ietf.org/html/rfc5545#page-17">RFC 5545 342 * p.17-8</a> 343 */ 344 public void addDelegatedTo(String uri) { 345 parameters.addDelegatedTo(uri); 346 } 347 348 @Override 349 public String getSentBy() { 350 return super.getSentBy(); 351 } 352 353 @Override 354 public void setSentBy(String uri) { 355 super.setSentBy(uri); 356 } 357 358 @Override 359 public String getCommonName() { 360 return name; 361 } 362 363 @Override 364 public void setCommonName(String commonName) { 365 this.name = commonName; 366 } 367 368 @Override 369 public String getDirectoryEntry() { 370 return super.getDirectoryEntry(); 371 } 372 373 @Override 374 public void setDirectoryEntry(String uri) { 375 super.setDirectoryEntry(uri); 376 } 377 378 /** 379 * Gets the language that the common name is written in. 380 */ 381 @Override 382 public String getLanguage() { 383 return super.getLanguage(); 384 } 385 386 /** 387 * Sets the language that the common name is written in. 388 */ 389 @Override 390 public void setLanguage(String language) { 391 super.setLanguage(language); 392 } 393 394 @Override 395 protected void validate(List<ICalComponent> components, ICalVersion version, List<Warning> warnings) { 396 //TODO 397 } 398}