001 package ezvcard.property; 002 003 import java.util.EnumSet; 004 import java.util.Set; 005 006 import ezvcard.VCardVersion; 007 import ezvcard.parameter.ExpertiseLevel; 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 professional subject area that the person has knowledge of. For 041 * example, if the person is a Java software engineer, he or she might list 042 * technologies such as "servlets", "SOAP", and "Spring". 043 * 044 * <p> 045 * <b>Code sample</b> 046 * </p> 047 * 048 * <pre class="brush:java"> 049 * VCard vcard = new VCard(); 050 * Expertise expertise = new Expertise("Java programming"); 051 * expertise.setLevel(ExpertiseLevel.EXPERT); 052 * vcard.addExpertise(expertise); 053 * </pre> 054 * 055 * <p> 056 * <b>Property name:</b> {@code EXPERTISE} 057 * </p> 058 * <p> 059 * <b>Supported versions:</b> {@code 4.0} 060 * </p> 061 * @author Michael Angstadt 062 * @see <a href="http://tools.ietf.org/html/rfc6715">RFC 6715</a> 063 */ 064 public class Expertise extends TextProperty implements HasAltId { 065 /** 066 * Creates an expertise property. 067 * @param skill the skill (e.g. "Java programming") 068 */ 069 public Expertise(String skill) { 070 super(skill); 071 } 072 073 @Override 074 public Set<VCardVersion> _supportedVersions() { 075 return EnumSet.of(VCardVersion.V4_0); 076 } 077 078 /** 079 * Gets the level of knowledge the person has for this skill. 080 * @return the skill level (e.g. "beginner") or null if not set 081 * @see VCardParameters#getLevel 082 */ 083 public ExpertiseLevel getLevel() { 084 String value = parameters.getLevel(); 085 return (value == null) ? null : ExpertiseLevel.get(value); 086 } 087 088 /** 089 * Sets the level of knowledge the person has for this skill. 090 * @param level the skill level (e.g. "beginner") or null to remove 091 * @see VCardParameters#setLevel 092 */ 093 public void setLevel(ExpertiseLevel level) { 094 parameters.setLevel(level.getValue()); 095 } 096 097 @Override 098 public Integer getIndex() { 099 return super.getIndex(); 100 } 101 102 @Override 103 public void setIndex(Integer index) { 104 super.setIndex(index); 105 } 106 107 /** 108 * Gets the TYPE parameter. 109 * @return the TYPE value (typically, this will be either "work" or "home") 110 * or null if it doesn't exist 111 */ 112 public String getType() { 113 return parameters.getType(); 114 } 115 116 /** 117 * Sets the TYPE parameter. 118 * @param type the TYPE value (this should be either "work" or "home") or 119 * null to remove 120 */ 121 public void setType(String type) { 122 parameters.setType(type); 123 } 124 125 @Override 126 public String getLanguage() { 127 return super.getLanguage(); 128 } 129 130 @Override 131 public void setLanguage(String language) { 132 super.setLanguage(language); 133 } 134 135 @Override 136 public Integer getPref() { 137 return super.getPref(); 138 } 139 140 @Override 141 public void setPref(Integer pref) { 142 super.setPref(pref); 143 } 144 145 //@Override 146 public String getAltId() { 147 return parameters.getAltId(); 148 } 149 150 //@Override 151 public void setAltId(String altId) { 152 parameters.setAltId(altId); 153 } 154 }