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