Debian Codegraph @

src/main/java/ezvcard/property/Language.java

raw symbols SCIP
1 package ezvcard.property;
2
3 import java.util.List;
4
5 import ezvcard.SupportedVersions;
6 import ezvcard.VCardVersion;
7 import ezvcard.parameter.Pid;
8
9 /*
10 Copyright (c) 2012-2023, Michael Angstadt
11 All rights reserved.
12
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions are met:
15
16 1. Redistributions of source code must retain the above copyright notice, this
17 list of conditions and the following disclaimer.
18 2. Redistributions in binary form must reproduce the above copyright notice,
19 this list of conditions and the following disclaimer in the documentation
20 and/or other materials provided with the distribution.
21
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
26 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33 The views and conclusions contained in the software and documentation are those
34 of the authors and should not be interpreted as representing official policies,
35 either expressed or implied, of the FreeBSD Project.
36 */
37
38 /**
39 * <p>
40 * Defines a language that the person speaks.
41 * </p>
42 *
43 * <p>
44 * <b>Code sample</b>
45 * </p>
46 *
47 * <pre class="brush:java">
48 * VCard vcard = new VCard();
49 *
50 * Language lang = new Language("en");
51 * lang.setPref(1); //most preferred
52 * vcard.addLanguage(lang);
53 *
54 * lang = new Language("fr");
55 * lang.setPref(2); //second-most preferred
56 * vcard.addLanguage(lang);
57 * </pre>
58 *
59 * <p>
60 * <b>Property name:</b> {@code LANG}
61 * </p>
62 * <p>
63 * <b>Supported versions:</b> {@code 4.0}
64 * </p>
65 *
66 * @author Michael Angstadt
67 * @see <a href="http://tools.ietf.org/html/rfc6350#page-37">RFC 6350 p.37</a>
68 */
69 @SupportedVersions(VCardVersion.V4_0)
70 public class Language extends TextProperty implements HasAltId {
71 /**
72 * Creates a language property.
73 * @param language the language (e.g. "en-ca")
74 */
75 public Language(String language) {
76 super(language);
77 }
78
79 /**
80 * Copy constructor.
81 * @param original the property to make a copy of
82 */
83 public Language(Language original) {
84 super(original);
85 }
86
87 /**
88 * Gets the TYPE parameter.
89 * <p>
90 * <b>Supported versions:</b> {@code 4.0}
91 * </p>
92 * @return the TYPE value (typically, this will be either "work" or "home")
93 * or null if it doesn't exist
94 */
95 public String getType() {
96 return parameters.getType();
97 }
98
99 /**
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 }