001 package ezvcard.property;
002
003 import java.util.EnumSet;
004 import java.util.List;
005 import java.util.Set;
006
007 import ezvcard.VCard;
008 import ezvcard.VCardVersion;
009 import ezvcard.Warning;
010
011 /*
012 Copyright (c) 2013, Michael Angstadt
013 All rights reserved.
014
015 Redistribution and use in source and binary forms, with or without
016 modification, are permitted provided that the following conditions are met:
017
018 1. Redistributions of source code must retain the above copyright notice, this
019 list of conditions and the following disclaimer.
020 2. Redistributions in binary form must reproduce the above copyright notice,
021 this list of conditions and the following disclaimer in the documentation
022 and/or other materials provided with the distribution.
023
024 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
025 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
026 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
027 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
028 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
029 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
030 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
031 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
032 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
033 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
034
035 The views and conclusions contained in the software and documentation are those
036 of the authors and should not be interpreted as representing official policies,
037 either expressed or implied, of the FreeBSD Project.
038 */
039
040 /**
041 * Marks the vCard as being an vCard.
042 *
043 * <p>
044 * <b>Code sample</b>
045 * </p>
046 *
047 * <pre class="brush:java">
048 * VCard vcard = new VCard();
049 * Profile profile = new Profile();
050 * vcard.setProfile(profile);
051 * </pre>
052 *
053 * <p>
054 * <b>Property name:</b> {@code PROFILE}
055 * </p>
056 * <p>
057 * <b>Supported versions:</b> {@code 3.0}
058 * </p>
059 * @author Michael Angstadt
060 */
061 public class Profile extends TextProperty {
062 public Profile() {
063 super("VCARD");
064 }
065
066 @Override
067 public Set<VCardVersion> _supportedVersions() {
068 return EnumSet.of(VCardVersion.V3_0);
069 }
070
071 @Override
072 protected void _validate(List<Warning> warnings, VCardVersion version, VCard vcard) {
073 if (!"VCARD".equalsIgnoreCase(value)) {
074 //see RFC 2426 p.5
075 warnings.add(new Warning(18, value));
076 }
077 }
078 }