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 that can be used to retrieve the most up-to-date version of the
038     * person's vCard.
039     * 
040     * <pre>
041     * VCard vcard = new VCard();
042     * SourceType source = new SourceType(&quot;http://www.company.com/employees/doe_john.vcf&quot;);
043     * vcard.addSource(source);
044     * </pre>
045     * 
046     * <p>
047     * vCard property name: SOURCE
048     * </p>
049     * <p>
050     * vCard versions: 3.0, 4.0
051     * </p>
052     * @author Michael Angstadt
053     */
054    public class SourceType extends UriType {
055            public static final String NAME = "SOURCE";
056    
057            public SourceType() {
058                    this(null);
059            }
060    
061            /**
062             * @param url the URL
063             */
064            public SourceType(String url) {
065                    super(NAME, url);
066            }
067    
068            /**
069             * Gets all PID parameter values.
070             * <p>
071             * vCard versions: 4.0
072             * </p>
073             * @return the PID values or empty set if there are none
074             * @see VCardSubTypes#getPids
075             */
076            public List<Integer[]> getPids() {
077                    return subTypes.getPids();
078            }
079    
080            /**
081             * Adds a PID value.
082             * <p>
083             * vCard versions: 4.0
084             * </p>
085             * @param localId the local ID
086             * @param clientPidMapRef the ID used to reference the property's globally
087             * unique identifier in the CLIENTPIDMAP property.
088             * @see VCardSubTypes#addPid(int, int)
089             */
090            public void addPid(int localId, int clientPidMapRef) {
091                    subTypes.addPid(localId, clientPidMapRef);
092            }
093    
094            /**
095             * Removes all PID values.
096             * <p>
097             * vCard versions: 4.0
098             * </p>
099             * @see VCardSubTypes#removePids
100             */
101            public void removePids() {
102                    subTypes.removePids();
103            }
104    
105            /**
106             * Gets the preference value.
107             * <p>
108             * vCard versions: 4.0
109             * </p>
110             * @return the preference value or null if it doesn't exist
111             * @see VCardSubTypes#getPref
112             */
113            public Integer getPref() {
114                    return subTypes.getPref();
115            }
116    
117            /**
118             * Sets the preference value.
119             * <p>
120             * vCard versions: 4.0
121             * </p>
122             * @param pref the preference value or null to remove
123             * @see VCardSubTypes#setPref
124             */
125            public void setPref(Integer pref) {
126                    subTypes.setPref(pref);
127            }
128    
129            /**
130             * Gets the ALTID.
131             * <p>
132             * vCard versions: 4.0
133             * </p>
134             * @return the ALTID or null if it doesn't exist
135             * @see VCardSubTypes#getAltId
136             */
137            public String getAltId() {
138                    return subTypes.getAltId();
139            }
140    
141            /**
142             * Sets the ALTID.
143             * <p>
144             * vCard versions: 4.0
145             * </p>
146             * @param altId the ALTID or null to remove
147             * @see VCardSubTypes#setAltId
148             */
149            public void setAltId(String altId) {
150                    subTypes.setAltId(altId);
151            }
152    }