001package ezvcard.property; 002 003import java.util.List; 004 005import ezvcard.SupportedVersions; 006import ezvcard.VCardVersion; 007import ezvcard.parameter.Pid; 008 009/* 010 Copyright (c) 2012-2023, Michael Angstadt 011 All rights reserved. 012 013 Redistribution and use in source and binary forms, with or without 014 modification, are permitted provided that the following conditions are met: 015 016 1. Redistributions of source code must retain the above copyright notice, this 017 list of conditions and the following disclaimer. 018 2. Redistributions in binary form must reproduce the above copyright notice, 019 this list of conditions and the following disclaimer in the documentation 020 and/or other materials provided with the distribution. 021 022 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 023 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 024 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 025 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 026 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 027 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 028 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 029 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 030 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 031 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 032 033 The views and conclusions contained in the software and documentation are those 034 of the authors and should not be interpreted as representing official policies, 035 either expressed or implied, of the FreeBSD Project. 036 */ 037 038/** 039 * <p> 040 * Defines a language that the person speaks. 041 * </p> 042 * 043 * <p> 044 * <b>Code sample</b> 045 * </p> 046 * 047 * <pre class="brush:java"> 048 * VCard vcard = new VCard(); 049 * 050 * Language lang = new Language("en"); 051 * lang.setPref(1); //most preferred 052 * vcard.addLanguage(lang); 053 * 054 * lang = new Language("fr"); 055 * lang.setPref(2); //second-most preferred 056 * vcard.addLanguage(lang); 057 * </pre> 058 * 059 * <p> 060 * <b>Property name:</b> {@code LANG} 061 * </p> 062 * <p> 063 * <b>Supported versions:</b> {@code 4.0} 064 * </p> 065 * 066 * @author Michael Angstadt 067 * @see <a href="http://tools.ietf.org/html/rfc6350#page-37">RFC 6350 p.37</a> 068 */ 069@SupportedVersions(VCardVersion.V4_0) 070public class Language extends TextProperty implements HasAltId { 071 /** 072 * Creates a language property. 073 * @param language the language (e.g. "en-ca") 074 */ 075 public Language(String language) { 076 super(language); 077 } 078 079 /** 080 * Copy constructor. 081 * @param original the property to make a copy of 082 */ 083 public Language(Language original) { 084 super(original); 085 } 086 087 /** 088 * Gets the TYPE parameter. 089 * <p> 090 * <b>Supported versions:</b> {@code 4.0} 091 * </p> 092 * @return the TYPE value (typically, this will be either "work" or "home") 093 * or null if it doesn't exist 094 */ 095 public String getType() { 096 return parameters.getType(); 097 } 098 099 /** 100 * Sets the TYPE parameter. 101 * <p> 102 * <b>Supported versions:</b> {@code 4.0} 103 * </p> 104 * @param type the TYPE value (this should be either "work" or "home") or 105 * null to remove 106 */ 107 public void setType(String type) { 108 parameters.setType(type); 109 } 110 111 @Override 112 public List<Pid> getPids() { 113 return super.getPids(); 114 } 115 116 @Override 117 public Integer getPref() { 118 return super.getPref(); 119 } 120 121 @Override 122 public void setPref(Integer pref) { 123 super.setPref(pref); 124 } 125 126 //@Override 127 public String getAltId() { 128 return parameters.getAltId(); 129 } 130 131 //@Override 132 public void setAltId(String altId) { 133 parameters.setAltId(altId); 134 } 135 136 @Override 137 public Language copy() { 138 return new Language(this); 139 } 140}