Debian Codegraph @

src/main/java/ezvcard/property/Logo.java

raw symbols SCIP
1 package ezvcard.property;
2
3 import java.io.IOException;
4 import java.io.InputStream;
5 import java.nio.file.Path;
6
7 import ezvcard.parameter.ImageType;
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 company logo.
41 * </p>
42 *
43 * <p>
44 * <b>Code sample (creating)</b>
45 * </p>
46 *
47 * <pre class="brush:java">
48 * VCard vcard = new VCard();
49 *
50 * //URL
51 * Logo logo = new Logo("http://www.ourcompany.com/our-logo.png", ImageType.PNG);
52 * vcard.addLogo(logo);
53 *
54 * //binary data
55 * byte data[] = ...
56 * logo = new Logo(data, ImageType.PNG);
57 * vcard.addLogo(logo);
58 * </pre>
59 *
60 * <p>
61 * <b>Code sample (retrieving)</b>
62 * </p>
63 *
64 * <pre class="brush:java">
65 * VCard vcard = ...
66 * for (Logo logo : vcard.getLogos()) {
67 * ImageType contentType = logo.getContentType(); //e.g. "image/png"
68 *
69 * String url = logo.getUrl();
70 * if (url != null) {
71 * //property value is a URL
72 * continue;
73 * }
74 *
75 * byte[] data = logo.getData();
76 * if (data != null) {
77 * //property value is binary data
78 * continue;
79 * }
80 * }
81 * </pre>
82 *
83 * <p>
84 * <b>Property name:</b> {@code LOGO}
85 * </p>
86 * <p>
87 * <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
88 * </p>
89 * @author Michael Angstadt
90 * @see <a href="http://tools.ietf.org/html/rfc6350#page-40">RFC 6350 p.40</a>
91 * @see <a href="http://tools.ietf.org/html/rfc2426#page-18">RFC 2426 p.18</a>
92 * @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.17</a>
93 */
94 public class Logo extends ImageProperty {
95 /**
96 * Creates a logo property.
97 * @param url the URL to the logo
98 * @param type the content type (e.g. PNG)
99 */
100 public Logo(String url, ImageType type) {
101 super(url, type);
102 }
103
104 /**
105 * Creates a logo property.
106 * @param data the binary data of the logo
107 * @param type the content type (e.g. PNG)
108 */
109 public Logo(byte[] data, ImageType type) {
110 super(data, type);
111 }
112
113 /**
114 * Creates a logo property.
115 * @param in an input stream to the binary data (will be closed)
116 * @param type the content type (e.g. PNG)
117 * @throws IOException if there's a problem reading from the input stream
118 */
119 public Logo(InputStream in, ImageType type) throws IOException {
120 super(in, type);
121 }
122
123 /**
124 * Creates a logo property.
125 * @param file the image file
126 * @param type the content type (e.g. PNG)
127 * @throws IOException if there's a problem reading from the file
128 */
129 public Logo(Path file, ImageType type) throws IOException {
130 super(file, type);
131 }
132
133 /**
134 * Copy constructor.
135 * @param original the property to make a copy of
136 */
137 public Logo(Logo original) {
138 super(original);
139 }
140
141 @Override
142 public String getLanguage() {
143 return super.getLanguage();
144 }
145
146 @Override
147 public void setLanguage(String language) {
148 super.setLanguage(language);
149 }
150
151 @Override
152 public Logo copy() {
153 return new Logo(this);
154 }
155 }