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     * The function that the person plays in his or her organization.
038     * 
039     * <pre>
040     * VCard vcard = new VCard();
041     * RoleType role = new RoleType(&quot;Project Leader&quot;);
042     * vcard.addRole(role);
043     * </pre>
044     * 
045     * <p>
046     * vCard property name: ROLE
047     * </p>
048     * <p>
049     * vCard versions: 2.1, 3.0, 4.0
050     * </p>
051     * @author Michael Angstadt
052     */
053    public class RoleType extends TextType {
054            public static final String NAME = "ROLE";
055    
056            public RoleType() {
057                    this(null);
058            }
059    
060            /**
061             * @param role the role (e.g. "Software Developer")
062             */
063            public RoleType(String role) {
064                    super(NAME, role);
065            }
066    
067            /**
068             * Gets the language that the address is written in.
069             * @return the language or null if not set
070             * @see VCardSubTypes#getLanguage
071             */
072            public String getLanguage() {
073                    return subTypes.getLanguage();
074            }
075    
076            /**
077             * Sets the language that the address is written in.
078             * @param language the language or null to remove
079             * @see VCardSubTypes#setLanguage
080             */
081            public void setLanguage(String language) {
082                    subTypes.setLanguage(language);
083            }
084    
085            /**
086             * Gets the TYPE parameter.
087             * <p>
088             * vCard versions: 4.0
089             * </p>
090             * @return the TYPE value (typically, this will be either "work" or "home")
091             * or null if it doesn't exist
092             */
093            public String getType() {
094                    return subTypes.getType();
095            }
096    
097            /**
098             * Sets the TYPE parameter.
099             * <p>
100             * vCard versions: 4.0
101             * </p>
102             * @param type the TYPE value (this should be either "work" or "home") or
103             * null to remove
104             */
105            public void setType(String type) {
106                    subTypes.setType(type);
107            }
108    
109            /**
110             * Gets all PID parameter values.
111             * <p>
112             * vCard versions: 4.0
113             * </p>
114             * @return the PID values or empty set if there are none
115             * @see VCardSubTypes#getPids
116             */
117            public List<Integer[]> getPids() {
118                    return subTypes.getPids();
119            }
120    
121            /**
122             * Adds a PID value.
123             * <p>
124             * vCard versions: 4.0
125             * </p>
126             * @param localId the local ID
127             * @param clientPidMapRef the ID used to reference the property's globally
128             * unique identifier in the CLIENTPIDMAP property.
129             * @see VCardSubTypes#addPid(int, int)
130             */
131            public void addPid(int localId, int clientPidMapRef) {
132                    subTypes.addPid(localId, clientPidMapRef);
133            }
134    
135            /**
136             * Removes all PID values.
137             * <p>
138             * vCard versions: 4.0
139             * </p>
140             * @see VCardSubTypes#removePids
141             */
142            public void removePids() {
143                    subTypes.removePids();
144            }
145    
146            /**
147             * Gets the preference value.
148             * <p>
149             * vCard versions: 4.0
150             * </p>
151             * @return the preference value or null if it doesn't exist
152             * @see VCardSubTypes#getPref
153             */
154            public Integer getPref() {
155                    return subTypes.getPref();
156            }
157    
158            /**
159             * Sets the preference value.
160             * <p>
161             * vCard versions: 4.0
162             * </p>
163             * @param pref the preference value or null to remove
164             * @see VCardSubTypes#setPref
165             */
166            public void setPref(Integer pref) {
167                    subTypes.setPref(pref);
168            }
169    
170            /**
171             * Gets the ALTID.
172             * <p>
173             * vCard versions: 4.0
174             * </p>
175             * @return the ALTID or null if it doesn't exist
176             * @see VCardSubTypes#getAltId
177             */
178            public String getAltId() {
179                    return subTypes.getAltId();
180            }
181    
182            /**
183             * Sets the ALTID.
184             * <p>
185             * vCard versions: 4.0
186             * </p>
187             * @param altId the ALTID or null to remove
188             * @see VCardSubTypes#setAltId
189             */
190            public void setAltId(String altId) {
191                    subTypes.setAltId(altId);
192            }
193    }