001 package ezvcard.property;
002
003 import java.util.EnumSet;
004 import java.util.Set;
005
006 import ezvcard.VCardVersion;
007 import ezvcard.parameter.InterestLevel;
008 import ezvcard.parameter.VCardParameters;
009
010 /*
011 Copyright (c) 2013, Michael Angstadt
012 All rights reserved.
013
014 Redistribution and use in source and binary forms, with or without
015 modification, are permitted provided that the following conditions are met:
016
017 1. Redistributions of source code must retain the above copyright notice, this
018 list of conditions and the following disclaimer.
019 2. Redistributions in binary form must reproduce the above copyright notice,
020 this list of conditions and the following disclaimer in the documentation
021 and/or other materials provided with the distribution.
022
023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
024 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
025 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
026 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
027 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
028 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
029 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
030 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
031 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
032 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
033
034 The views and conclusions contained in the software and documentation are those
035 of the authors and should not be interpreted as representing official policies,
036 either expressed or implied, of the FreeBSD Project.
037 */
038
039 /**
040 * Defines a recreational activity that the person is interested in. For
041 * example, if a person has a INTEREST of "hockey", it would mean that he likes
042 * to watch hockey games. Someone who likes to actually <i>play</i> hockey would
043 * list "hockey" as a {@link Hobby} instead.
044 *
045 * <p>
046 * <b>Code sample</b>
047 * </p>
048 *
049 * <pre class="brush:java">
050 * //someone who attends all of his favorite hockey team's games in person.
051 * VCard vcard = new VCard();
052 * Interest interest = new Interest("hockey");
053 * interest.setLevel(InterestLevel.HIGH);
054 * vcard.addInterest(interest);
055 * </pre>
056 *
057 * <p>
058 * <b>Property name:</b> {@code INTEREST}
059 * </p>
060 * <p>
061 * <b>Supported versions:</b> {@code 4.0}
062 * </p>
063 * @author Michael Angstadt
064 * @see <a href="http://tools.ietf.org/html/rfc6715">RFC 6715</a>
065 */
066 public class Interest extends TextProperty implements HasAltId {
067 /**
068 * Creates an interest property.
069 * @param interest the hobby (e.g. "wind surfing")
070 */
071 public Interest(String interest) {
072 super(interest);
073 }
074
075 @Override
076 public Set<VCardVersion> _supportedVersions() {
077 return EnumSet.of(VCardVersion.V4_0);
078 }
079
080 /**
081 * Gets the level of the person's interest.
082 * @return the interest level (e.g. "low") or null if not set
083 * @see VCardParameters#getLevel
084 */
085 public InterestLevel getLevel() {
086 String value = parameters.getLevel();
087 return (value == null) ? null : InterestLevel.get(value);
088 }
089
090 /**
091 * Sets the level of the person's interest.
092 * @param level the level (e.g. "low") or null to remove
093 * @see VCardParameters#setLevel
094 */
095 public void setLevel(InterestLevel level) {
096 parameters.setLevel(level.getValue());
097 }
098
099 @Override
100 public Integer getIndex() {
101 return super.getIndex();
102 }
103
104 @Override
105 public void setIndex(Integer index) {
106 super.setIndex(index);
107 }
108
109 /**
110 * Gets the TYPE parameter.
111 * @return the TYPE value (typically, this will be either "work" or "home")
112 * or null if it doesn't exist
113 */
114 public String getType() {
115 return parameters.getType();
116 }
117
118 /**
119 * Sets the TYPE parameter.
120 * @param type the TYPE value (this should be either "work" or "home") or
121 * null to remove
122 */
123 public void setType(String type) {
124 parameters.setType(type);
125 }
126
127 @Override
128 public String getLanguage() {
129 return super.getLanguage();
130 }
131
132 @Override
133 public void setLanguage(String language) {
134 super.setLanguage(language);
135 }
136
137 @Override
138 public Integer getPref() {
139 return super.getPref();
140 }
141
142 @Override
143 public void setPref(Integer pref) {
144 super.setPref(pref);
145 }
146
147 //@Override
148 public String getAltId() {
149 return parameters.getAltId();
150 }
151
152 //@Override
153 public void setAltId(String altId) {
154 parameters.setAltId(altId);
155 }
156 }