001 package ezvcard.types;
002
003 import ezvcard.VCardVersion;
004
005 /*
006 Copyright (c) 2012, Michael Angstadt
007 All rights reserved.
008
009 Redistribution and use in source and binary forms, with or without
010 modification, are permitted provided that the following conditions are met:
011
012 1. Redistributions of source code must retain the above copyright notice, this
013 list of conditions and the following disclaimer.
014 2. Redistributions in binary form must reproduce the above copyright notice,
015 this list of conditions and the following disclaimer in the documentation
016 and/or other materials provided with the distribution.
017
018 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
019 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
020 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
021 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
022 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
023 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
024 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
025 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
026 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
027 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
028
029 The views and conclusions contained in the software and documentation are those
030 of the authors and should not be interpreted as representing official policies,
031 either expressed or implied, of the FreeBSD Project.
032 */
033
034 /**
035 * Defines the type of entity that this vCard represents, such as an individual
036 * or an organization.
037 *
038 * <p>
039 * <b>Setting the KIND</b>
040 * </p>
041 *
042 * <pre>
043 * //use static methods to create a KindType object
044 * VCard vcard = new VCard();
045 * KindType kind = KindType.individual();
046 * vcard.setKind(kind);
047 * </pre>
048 *
049 * <p>
050 * <b>Getting the KIND</b>
051 * </p>
052 *
053 * <pre>
054 * //use "is*" methods to determine the KindType value
055 * VCard vcard = ...
056 * KindType kind = vcard.getKind();
057 * if (kind != null){
058 * if (kind.isIndividual()){
059 * ...
060 * } else if (kind.isGroup()){
061 * ...
062 * }
063 * ...
064 * }
065 * </pre>
066 *
067 * <p>
068 * vCard property name: KIND
069 * </p>
070 * <p>
071 * vCard versions: 4.0
072 * </p>
073 * @author Michael Angstadt
074 */
075 public class KindType extends TextType {
076 public static final String NAME = "KIND";
077
078 public static final String INDIVIDUAL = "individual";
079 public static final String GROUP = "group";
080 public static final String ORG = "org";
081 public static final String LOCATION = "location";
082 public static final String APPLICATION = "application";
083 public static final String DEVICE = "device";
084
085 public KindType() {
086 super(NAME);
087 }
088
089 /**
090 * Use of this constructor is discouraged. Please use one of the static
091 * methods to create a new KIND type.
092 * @param kind the kind value (e.g. "group")
093 */
094 public KindType(String kind) {
095 super(NAME, kind);
096 }
097
098 /**
099 * Determines if the value is set to "individual".
100 * @return true if the value is "individual", false if not
101 */
102 public boolean isIndividual() {
103 return INDIVIDUAL.equals(value);
104 }
105
106 /**
107 * Determines if the value is set to "group".
108 * @return true if the value is "group", false if not
109 */
110 public boolean isGroup() {
111 return GROUP.equals(value);
112 }
113
114 /**
115 * Determines if the value is set to "org".
116 * @return true if the value is "org", false if not
117 */
118 public boolean isOrg() {
119 return ORG.equals(value);
120 }
121
122 /**
123 * Determines if the value is set to "location".
124 * @return true if the value is "location", false if not
125 */
126 public boolean isLocation() {
127 return LOCATION.equals(value);
128 }
129
130 /**
131 * Determines if the value is set to "application".
132 * @return true if the value is "application", false if not
133 * @see <a href="http://tools.ietf.org/html/rfc6473">RFC 6473</a>
134 */
135 public boolean isApplication() {
136 return APPLICATION.equals(value);
137 }
138
139 /**
140 * Determines if the value is set to "device".
141 * @return true if the value is "device", false if not
142 * @see <a href="http://tools.ietf.org/html/rfc6869">RFC 6869</a>
143 */
144 public boolean isDevice() {
145 return DEVICE.equals(value);
146 }
147
148 /**
149 * Creates a new KIND type whose value is set to "individual".
150 * @return the new KIND type
151 */
152 public static KindType individual() {
153 return new KindType(INDIVIDUAL);
154 }
155
156 /**
157 * Creates a new KIND type whose value is set to "group".
158 * @return the new KIND type
159 */
160 public static KindType group() {
161 return new KindType(GROUP);
162 }
163
164 /**
165 * Creates a new KIND type whose value is set to "org".
166 * @return the new KIND type
167 */
168 public static KindType org() {
169 return new KindType(ORG);
170 }
171
172 /**
173 * Creates a new KIND type whose value is set to "location".
174 * @return the new KIND type
175 */
176 public static KindType location() {
177 return new KindType(LOCATION);
178 }
179
180 /**
181 * Creates a new KIND type whose value is set to "application".
182 * @return the new KIND type
183 * @see <a href="http://tools.ietf.org/html/rfc6473">RFC 6473</a>
184 */
185 public static KindType application() {
186 return new KindType(APPLICATION);
187 }
188
189 /**
190 * Creates a new KIND type whose value is set to "device".
191 * @return the new KIND type
192 * @see <a href="http://tools.ietf.org/html/rfc6869">RFC 6869</a>
193 */
194 public static KindType device() {
195 return new KindType(DEVICE);
196 }
197
198 @Override
199 public VCardVersion[] getSupportedVersions() {
200 return new VCardVersion[] { VCardVersion.V4_0 };
201 }
202 }