001    package biweekly.property;
002    
003    import java.util.List;
004    
005    import biweekly.component.VAlarm;
006    import biweekly.parameter.CalendarUserType;
007    import biweekly.parameter.ParticipationStatus;
008    import 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>Examples:</b>
048     * 
049     * <pre class="brush:java">
050     * Attendee attendee = Attendee.email("johndoe@example.com")
051     * attendee.setCommonName("John Doe");
052     * attendee.setRsvp(true);
053     * attendee.setRole(Role.CHAIR);
054     * attendee.setParticipationStatus(ParticipationStatus.ACCEPTED);
055     * </pre>
056     * 
057     * </p>
058     * @author Michael Angstadt
059     * @rfc 5545 p.107-9
060     */
061    public class Attendee extends TextProperty {
062            /**
063             * Creates an attendee property.
064             * @param uri a URI representing the attendee (typically, an email address,
065             * e.g. "mailto:johndoe@example.com")
066             */
067            public Attendee(String uri) {
068                    super(uri);
069            }
070    
071            /**
072             * Creates an attendee property using an email address as its value.
073             * @param email the email address (e.g. "johndoe@example.com")
074             * @return the property
075             */
076            public static Attendee email(String email) {
077                    return new Attendee("mailto:" + email);
078            }
079    
080            /**
081             * Gets the type of user the attendee is (for example, an "individual" or a
082             * "room").
083             * @return the calendar user type or null if not set
084             * @rfc 5545 p.16
085             */
086            public CalendarUserType getCalendarUserType() {
087                    return parameters.getCalendarUserType();
088            }
089    
090            /**
091             * Sets the type of user the attendee is (for example, an "individual" or a
092             * "room").
093             * @param cutype the calendar user type or null to remove
094             * @rfc 5545 p.16
095             */
096            public void setCalendarUserType(CalendarUserType cutype) {
097                    parameters.setCalendarUserType(cutype);
098            }
099    
100            /**
101             * Gets the groups that the attendee is a member of.
102             * @return the group URIs (typically, these are email address URIs, e.g.
103             * "mailto:mailinglist@example.com")
104             * @rfc 5545 p.21-2
105             */
106            public List<String> getMembers() {
107                    return parameters.getMembers();
108            }
109    
110            /**
111             * Adds a group that the attendee is a member of.
112             * @param uri the group URI (typically, an email address URI, e.g.
113             * "mailto:mailinglist@example.com")
114             * @rfc 5545 p.21-2
115             */
116            public void addMember(String uri) {
117                    parameters.addMember(uri);
118            }
119    
120            /**
121             * Gets the attendee's role (for example, "chair" or
122             * "required participant").
123             * @return the role or null if not set
124             * @rfc 5545 p.25-6
125             */
126            public Role getRole() {
127                    return parameters.getRole();
128            }
129    
130            /**
131             * Sets the attendee's role (for example, "chair" or
132             * "required participant").
133             * @param role the role or null to remove
134             * @rfc 5545 p.25-6
135             */
136            public void setRole(Role role) {
137                    parameters.setRole(role);
138            }
139    
140            /**
141             * Gets the attendee's level of participation.
142             * @return the participation status or null if not set
143             * @rfc 5545 p.22-3
144             */
145            public ParticipationStatus getParticipationStatus() {
146                    return parameters.getParticipationStatus();
147            }
148    
149            /**
150             * Sets the attendee's level of participation.
151             * @param status the participation status or null to remove
152             * @rfc 5545 p.22-3
153             */
154            public void setParticipationStatus(ParticipationStatus status) {
155                    parameters.setParticipationStatus(status);
156            }
157    
158            /**
159             * Gets whether the organizer requests a response from the attendee.
160             * @return true if an RSVP is requested, false if not, null if not set
161             * @rfc 5545 p.26-7
162             */
163            public Boolean getRsvp() {
164                    return parameters.getRsvp();
165            }
166    
167            /**
168             * Sets whether the organizer requests a response from the attendee.
169             * @param rsvp true if an RSVP has been requested, false if not, null to
170             * remove
171             * @rfc 5545 p.26-7
172             */
173            public void setRsvp(Boolean rsvp) {
174                    parameters.setRsvp(rsvp);
175            }
176    
177            /**
178             * Gets the people who have delegated their responsibility to the attendee.
179             * @return the delegators (typically email URIs, e.g.
180             * "mailto:janedoe@example.com")
181             * @rfc 5545 p.17
182             */
183            public List<String> getDelegatedFrom() {
184                    return parameters.getDelegatedFrom();
185            }
186    
187            /**
188             * Adds a person who has delegated his or her responsibility to the
189             * attendee.
190             * @param uri the delegator (typically an email URI, e.g.
191             * "mailto:janedoe@example.com")
192             * @rfc 5545 p.17
193             */
194            public void addDelegatedFrom(String uri) {
195                    parameters.addDelegatedFrom(uri);
196            }
197    
198            /**
199             * Gets the people to which the attendee has delegated his or her
200             * responsibility.
201             * @return the delegatees (typically email URIs, e.g.
202             * "mailto:janedoe@example.com")
203             * @rfc 5545 p.17-8
204             */
205            public List<String> getDelegatedTo() {
206                    return parameters.getDelegatedTo();
207            }
208    
209            /**
210             * Adds a person to which the attendee has delegated his or her
211             * responsibility.
212             * @param uri the delegatee (typically an email URI, e.g.
213             * "mailto:janedoe@example.com")
214             * @rfc 5545 p.17-8
215             */
216            public void addDelegatedTo(String uri) {
217                    parameters.addDelegatedTo(uri);
218            }
219    
220            @Override
221            public String getSentBy() {
222                    return super.getSentBy();
223            }
224    
225            @Override
226            public void setSentBy(String uri) {
227                    super.setSentBy(uri);
228            }
229    
230            @Override
231            public String getCommonName() {
232                    return super.getCommonName();
233            }
234    
235            @Override
236            public void setCommonName(String commonName) {
237                    super.setCommonName(commonName);
238            }
239    
240            @Override
241            public String getDirectoryEntry() {
242                    return super.getDirectoryEntry();
243            }
244    
245            @Override
246            public void setDirectoryEntry(String uri) {
247                    super.setDirectoryEntry(uri);
248            }
249    
250            /**
251             * Gets the language that the common name parameter is written in.
252             */
253            @Override
254            public String getLanguage() {
255                    return super.getLanguage();
256            }
257    
258            /**
259             * Sets the language that the common name parameter is written in.
260             */
261            @Override
262            public void setLanguage(String language) {
263                    super.setLanguage(language);
264            }
265    
266    }