001 package ezvcard.types;
002
003 import ezvcard.VCardSubTypes;
004 import ezvcard.VCardVersion;
005 import ezvcard.parameters.ExpertiseLevelParameter;
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 * Defines a professional subject area that the person has knowledge of. For
038 * example, if the person is a Java software engineer, he or she might list
039 * technologies such as "servlets", "SOAP", and "Spring".
040 *
041 * <pre>
042 * VCard vcard = new VCard();
043 * ExpertiseType expertise = new ExpertiseType("Java programming");
044 * expertise.setLevel(ExpertiseLevelParameter.EXPERT);
045 * vcard.addExpertise(expertise);
046 * </pre>
047 *
048 * <p>
049 * vCard property name: EXPERTISE
050 * </p>
051 * <p>
052 * vCard versions: 4.0
053 * </p>
054 * @author Michael Angstadt
055 * @see <a href="http://tools.ietf.org/html/rfc6715">RFC 6715</a>
056 */
057 public class ExpertiseType extends TextType {
058 public static final String NAME = "EXPERTISE";
059
060 public ExpertiseType() {
061 super(NAME);
062 }
063
064 /**
065 * @param skill the skill (e.g. "Java programming")
066 */
067 public ExpertiseType(String skill) {
068 super(NAME, skill);
069 }
070
071 @Override
072 public VCardVersion[] getSupportedVersions() {
073 return new VCardVersion[] { VCardVersion.V4_0 };
074 }
075
076 /**
077 * Gets the level of knowledge the person has for this skill.
078 * @return the skill level (e.g. "beginner") or null if not set
079 * @see VCardSubTypes#getLevel
080 */
081 public ExpertiseLevelParameter getLevel() {
082 String value = subTypes.getLevel();
083 if (value == null) {
084 return null;
085 }
086 ExpertiseLevelParameter p = ExpertiseLevelParameter.valueOf(value);
087 if (p == null) {
088 p = new ExpertiseLevelParameter(value);
089 }
090 return p;
091 }
092
093 /**
094 * Sets the level of knowledge the person has for this skill.
095 * @param level the skill level (e.g. "beginner") or null to remove
096 * @see VCardSubTypes#setLevel
097 */
098 public void setLevel(ExpertiseLevelParameter level) {
099 subTypes.setLevel(level.getValue());
100 }
101
102 /**
103 * Gets the INDEX parameter.
104 * @return the INDEX or null if not set
105 * @see VCardSubTypes#getIndex
106 */
107 public Integer getIndex() {
108 return subTypes.getIndex();
109 }
110
111 /**
112 * Sets the INDEX parameter.
113 * @param index the INDEX or null to remove
114 * @see VCardSubTypes#setIndex
115 */
116 public void setIndex(Integer index) {
117 subTypes.setIndex(index);
118 }
119
120 /**
121 * Gets the TYPE parameter.
122 * @return the TYPE value (typically, this will be either "work" or "home")
123 * or null if it doesn't exist
124 */
125 public String getType() {
126 return subTypes.getType();
127 }
128
129 /**
130 * Sets the TYPE parameter.
131 * @param type the TYPE value (this should be either "work" or "home") or
132 * null to remove
133 */
134 public void setType(String type) {
135 subTypes.setType(type);
136 }
137
138 /**
139 * Gets the language that the skill description is written in.
140 * @return the language or null if not set
141 * @see VCardSubTypes#getLanguage
142 */
143 public String getLanguage() {
144 return subTypes.getLanguage();
145 }
146
147 /**
148 * Sets the language that the skill description is written in.
149 * @param language the language or null to remove
150 * @see VCardSubTypes#setLanguage
151 */
152 public void setLanguage(String language) {
153 subTypes.setLanguage(language);
154 }
155
156 /**
157 * Gets the preference value.
158 * <p>
159 * vCard versions: 4.0
160 * </p>
161 * @return the preference value or null if it doesn't exist
162 * @see VCardSubTypes#getPref
163 */
164 public Integer getPref() {
165 return subTypes.getPref();
166 }
167
168 /**
169 * Sets the preference value.
170 * <p>
171 * vCard versions: 4.0
172 * </p>
173 * @param pref the preference value or null to remove
174 * @see VCardSubTypes#setPref
175 */
176 public void setPref(Integer pref) {
177 subTypes.setPref(pref);
178 }
179
180 /**
181 * Gets the ALTID.
182 * <p>
183 * vCard versions: 4.0
184 * </p>
185 * @return the ALTID or null if it doesn't exist
186 * @see VCardSubTypes#getAltId
187 */
188 public String getAltId() {
189 return subTypes.getAltId();
190 }
191
192 /**
193 * Sets the ALTID.
194 * <p>
195 * vCard versions: 4.0
196 * </p>
197 * @param altId the ALTID or null to remove
198 * @see VCardSubTypes#setAltId
199 */
200 public void setAltId(String altId) {
201 subTypes.setAltId(altId);
202 }
203 }