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