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