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 * A free-form text field that contains miscellaneous information.
038 *
039 * <pre>
040 * VCard vcard = new VCard();
041 * NoteType note = new NoteType("This is a\nmiscellaneous comment."); //can contain newlines
042 * note.setLanguage("en-us");
043 * vcard.addNote(note);
044 * </pre>
045 *
046 * <p>
047 * vCard property name: NOTE
048 * </p>
049 * <p>
050 * vCard versions: 2.1, 3.0, 4.0
051 * </p>
052 * @author Michael Angstadt
053 */
054 public class NoteType extends TextType {
055 public static final String NAME = "NOTE";
056
057 public NoteType() {
058 this(null);
059 }
060
061 /**
062 * @param note the note text
063 */
064 public NoteType(String note) {
065 super(NAME, note);
066 }
067
068 /**
069 * Gets all PID parameter values.
070 * <p>
071 * vCard versions: 4.0
072 * </p>
073 * @return the PID values or empty set if there are none
074 * @see VCardSubTypes#getPids
075 */
076 public List<Integer[]> getPids() {
077 return subTypes.getPids();
078 }
079
080 /**
081 * Adds a PID value.
082 * <p>
083 * vCard versions: 4.0
084 * </p>
085 * @param localId the local ID
086 * @param clientPidMapRef the ID used to reference the property's globally
087 * unique identifier in the CLIENTPIDMAP property.
088 * @see VCardSubTypes#addPid(int, int)
089 */
090 public void addPid(int localId, int clientPidMapRef) {
091 subTypes.addPid(localId, clientPidMapRef);
092 }
093
094 /**
095 * Removes all PID values.
096 * <p>
097 * vCard versions: 4.0
098 * </p>
099 * @see VCardSubTypes#removePids
100 */
101 public void removePids() {
102 subTypes.removePids();
103 }
104
105 /**
106 * Gets the preference value.
107 * <p>
108 * vCard versions: 4.0
109 * </p>
110 * @return the preference value or null if it doesn't exist
111 * @see VCardSubTypes#getPref
112 */
113 public Integer getPref() {
114 return subTypes.getPref();
115 }
116
117 /**
118 * Sets the preference value.
119 * <p>
120 * vCard versions: 4.0
121 * </p>
122 * @param pref the preference value or null to remove
123 * @see VCardSubTypes#setPref
124 */
125 public void setPref(Integer pref) {
126 subTypes.setPref(pref);
127 }
128
129 /**
130 * Gets the ALTID.
131 * <p>
132 * vCard versions: 4.0
133 * </p>
134 * @return the ALTID or null if it doesn't exist
135 * @see VCardSubTypes#getAltId
136 */
137 public String getAltId() {
138 return subTypes.getAltId();
139 }
140
141 /**
142 * Sets the ALTID.
143 * <p>
144 * vCard versions: 4.0
145 * </p>
146 * @param altId the ALTID or null to remove
147 * @see VCardSubTypes#setAltId
148 */
149 public void setAltId(String altId) {
150 subTypes.setAltId(altId);
151 }
152
153 /**
154 * Gets the TYPE parameter.
155 * <p>
156 * vCard versions: 4.0
157 * </p>
158 * @return the TYPE value (typically, this will be either "work" or "home")
159 * or null if it doesn't exist
160 */
161 public String getType() {
162 return subTypes.getType();
163 }
164
165 /**
166 * Sets the TYPE parameter.
167 * <p>
168 * vCard versions: 4.0
169 * </p>
170 * @param type the TYPE value (this should be either "work" or "home") or
171 * null to remove
172 */
173 public void setType(String type) {
174 subTypes.setType(type);
175 }
176
177 /**
178 * Gets the language the note is written in.
179 * @return the language or null if not set
180 * @see VCardSubTypes#getLanguage
181 */
182 public String getLanguage() {
183 return subTypes.getLanguage();
184 }
185
186 /**
187 * Sets the language that the note is written in.
188 * @param language the language or null to remove
189 * @see VCardSubTypes#setLanguage
190 */
191 public void setLanguage(String language) {
192 subTypes.setLanguage(language);
193 }
194 }