001    package ezvcard.types;
002    
003    import java.util.List;
004    
005    import ezvcard.VCardSubTypes;
006    import ezvcard.VCardVersion;
007    
008    /*
009     Copyright (c) 2012, Michael Angstadt
010     All rights reserved.
011    
012     Redistribution and use in source and binary forms, with or without
013     modification, are permitted provided that the following conditions are met: 
014    
015     1. Redistributions of source code must retain the above copyright notice, this
016     list of conditions and the following disclaimer. 
017     2. Redistributions in binary form must reproduce the above copyright notice,
018     this list of conditions and the following disclaimer in the documentation
019     and/or other materials provided with the distribution. 
020    
021     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
022     ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
023     WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
024     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
025     ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
026     (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
027     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
028     ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
029     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
030     SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
031    
032     The views and conclusions contained in the software and documentation are those
033     of the authors and should not be interpreted as representing official policies, 
034     either expressed or implied, of the FreeBSD Project.
035     */
036    
037    /**
038     * A URL to the person's calendar.
039     * 
040     * <pre>
041     * VCard vcard = new VCard();
042     * CalendarUriType caluri = new CalendarUriType(&quot;http://www.ibm.com/janedoe/calendar&quot;);
043     * vcard.addCalendarUri(caluri);
044     * </pre>
045     * 
046     * <p>
047     * vCard property name: CALURI
048     * </p>
049     * <p>
050     * vCard versions: 4.0
051     * </p>
052     * @author Michael Angstadt
053     */
054    public class CalendarUriType extends UriType {
055            public static final String NAME = "CALURI";
056    
057            public CalendarUriType() {
058                    super(NAME);
059            }
060    
061            /**
062             * @param uri the calendar URI
063             */
064            public CalendarUriType(String uri) {
065                    super(NAME, uri);
066            }
067    
068            /**
069             * Gets the MEDIATYPE parameter.
070             * <p>
071             * vCard versions: 4.0
072             * </p>
073             * @return the media type or null if not set
074             */
075            public String getMediaType() {
076                    return subTypes.getMediaType();
077            }
078    
079            /**
080             * Sets the MEDIATYPE parameter.
081             * <p>
082             * vCard versions: 4.0
083             * </p>
084             * @param mediaType the media type or null to remove
085             */
086            public void setMediaType(String mediaType) {
087                    subTypes.setMediaType(mediaType);
088            }
089    
090            /**
091             * Gets all PID parameter values.
092             * <p>
093             * vCard versions: 4.0
094             * </p>
095             * @return the PID values or empty set if there are none
096             * @see VCardSubTypes#getPids
097             */
098            public List<Integer[]> getPids() {
099                    return subTypes.getPids();
100            }
101    
102            /**
103             * Adds a PID value.
104             * <p>
105             * vCard versions: 4.0
106             * </p>
107             * @param localId the local ID
108             * @param clientPidMapRef the ID used to reference the property's globally
109             * unique identifier in the CLIENTPIDMAP property.
110             * @see VCardSubTypes#addPid(int, int)
111             */
112            public void addPid(int localId, int clientPidMapRef) {
113                    subTypes.addPid(localId, clientPidMapRef);
114            }
115    
116            /**
117             * Removes all PID values.
118             * <p>
119             * vCard versions: 4.0
120             * </p>
121             * @see VCardSubTypes#removePids
122             */
123            public void removePids() {
124                    subTypes.removePids();
125            }
126    
127            /**
128             * Gets the preference value.
129             * <p>
130             * vCard versions: 4.0
131             * </p>
132             * @return the preference value or null if it doesn't exist
133             * @see VCardSubTypes#getPref
134             */
135            public Integer getPref() {
136                    return subTypes.getPref();
137            }
138    
139            /**
140             * Sets the preference value.
141             * <p>
142             * vCard versions: 4.0
143             * </p>
144             * @param pref the preference value or null to remove
145             * @see VCardSubTypes#setPref
146             */
147            public void setPref(Integer pref) {
148                    subTypes.setPref(pref);
149            }
150    
151            /**
152             * Gets the ALTID.
153             * <p>
154             * vCard versions: 4.0
155             * </p>
156             * @return the ALTID or null if it doesn't exist
157             * @see VCardSubTypes#getAltId
158             */
159            public String getAltId() {
160                    return subTypes.getAltId();
161            }
162    
163            /**
164             * Sets the ALTID.
165             * <p>
166             * vCard versions: 4.0
167             * </p>
168             * @param altId the ALTID or null to remove
169             * @see VCardSubTypes#setAltId
170             */
171            public void setAltId(String altId) {
172                    subTypes.setAltId(altId);
173            }
174    
175            /**
176             * Gets the TYPE parameter.
177             * <p>
178             * vCard versions: 4.0
179             * </p>
180             * @return the TYPE value (typically, this will be either "work" or "home")
181             * or null if it doesn't exist
182             */
183            public String getType() {
184                    return subTypes.getType();
185            }
186    
187            /**
188             * Sets the TYPE parameter.
189             * <p>
190             * vCard versions: 4.0
191             * </p>
192             * @param type the TYPE value (this should be either "work" or "home") or
193             * null to remove
194             */
195            public void setType(String type) {
196                    subTypes.setType(type);
197            }
198    
199            @Override
200            public VCardVersion[] getSupportedVersions() {
201                    return new VCardVersion[] { VCardVersion.V4_0 };
202            }
203    }