001 package ezvcard.types; 002 003 import java.util.List; 004 005 import ezvcard.VCardSubTypes; 006 007 /* 008 Copyright (c) 2012, Michael Angstadt 009 All rights reserved. 010 011 Redistribution and use in source and binary forms, with or without 012 modification, are permitted provided that the following conditions are met: 013 014 1. Redistributions of source code must retain the above copyright notice, this 015 list of conditions and the following disclaimer. 016 2. Redistributions in binary form must reproduce the above copyright notice, 017 this list of conditions and the following disclaimer in the documentation 018 and/or other materials provided with the distribution. 019 020 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 021 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 022 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 023 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 024 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 025 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 026 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 027 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 028 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 029 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 030 031 The views and conclusions contained in the software and documentation are those 032 of the authors and should not be interpreted as representing official policies, 033 either expressed or implied, of the FreeBSD Project. 034 */ 035 036 /** 037 * Shows how the person's name should be displayed. 038 * 039 * <pre> 040 * VCard vcard = new VCard(); 041 * FormattedNameType fn = new FormattedNameType("Dr. Gregory House M.D."); 042 * vcard.setFormattedName(fn); 043 * </pre> 044 * 045 * <p> 046 * vCard property name: FN 047 * </p> 048 * <p> 049 * vCard versions: 2.1, 3.0, 4.0 050 * </p> 051 * @author Michael Angstadt 052 */ 053 public class FormattedNameType extends TextType { 054 public static final String NAME = "FN"; 055 056 public FormattedNameType() { 057 this(null); 058 } 059 060 /** 061 * @param name the person's name 062 */ 063 public FormattedNameType(String name) { 064 super(NAME, name); 065 } 066 067 /** 068 * Gets the TYPE parameter. 069 * <p> 070 * vCard versions: 4.0 071 * </p> 072 * @return the TYPE value (typically, this will be either "work" or "home") 073 * or null if it doesn't exist 074 */ 075 public String getType() { 076 return subTypes.getType(); 077 } 078 079 /** 080 * Sets the TYPE parameter. 081 * <p> 082 * vCard versions: 4.0 083 * </p> 084 * @param type the TYPE value (this should be either "work" or "home") or 085 * null to remove 086 */ 087 public void setType(String type) { 088 subTypes.setType(type); 089 } 090 091 /** 092 * Gets the language the name is written in. 093 * @return the language or null if not set 094 * @see VCardSubTypes#getLanguage 095 */ 096 public String getLanguage() { 097 return subTypes.getLanguage(); 098 } 099 100 /** 101 * Sets the language the name is written in. 102 * @param language the language or null to remove 103 * @see VCardSubTypes#setLanguage 104 */ 105 public void setLanguage(String language) { 106 subTypes.setLanguage(language); 107 } 108 109 /** 110 * Gets all PID parameter values. 111 * <p> 112 * vCard versions: 4.0 113 * </p> 114 * @return the PID values or empty set if there are none 115 * @see VCardSubTypes#getPids 116 */ 117 public List<Integer[]> getPids() { 118 return subTypes.getPids(); 119 } 120 121 /** 122 * Adds a PID value. 123 * <p> 124 * vCard versions: 4.0 125 * </p> 126 * @param localId the local ID 127 * @param clientPidMapRef the ID used to reference the property's globally 128 * unique identifier in the CLIENTPIDMAP property. 129 * @see VCardSubTypes#addPid(int, int) 130 */ 131 public void addPid(int localId, int clientPidMapRef) { 132 subTypes.addPid(localId, clientPidMapRef); 133 } 134 135 /** 136 * Removes all PID values. 137 * <p> 138 * vCard versions: 4.0 139 * </p> 140 * @see VCardSubTypes#removePids 141 */ 142 public void removePids() { 143 subTypes.removePids(); 144 } 145 146 /** 147 * Gets the preference value. 148 * <p> 149 * vCard versions: 4.0 150 * </p> 151 * @return the preference value or null if it doesn't exist 152 * @see VCardSubTypes#getPref 153 */ 154 public Integer getPref() { 155 return subTypes.getPref(); 156 } 157 158 /** 159 * Sets the preference value. 160 * <p> 161 * vCard versions: 4.0 162 * </p> 163 * @param pref the preference value or null to remove 164 * @see VCardSubTypes#setPref 165 */ 166 public void setPref(Integer pref) { 167 subTypes.setPref(pref); 168 } 169 170 /** 171 * Gets the ALTID. 172 * <p> 173 * vCard versions: 4.0 174 * </p> 175 * @return the ALTID or null if it doesn't exist 176 * @see VCardSubTypes#getAltId 177 */ 178 public String getAltId() { 179 return subTypes.getAltId(); 180 } 181 182 /** 183 * Sets the ALTID. 184 * <p> 185 * vCard versions: 4.0 186 * </p> 187 * @param altId the ALTID or null to remove 188 * @see VCardSubTypes#setAltId 189 */ 190 public void setAltId(String altId) { 191 subTypes.setAltId(altId); 192 } 193 }