| 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 | * Represents a vCard property that stores image data. |
| 40 | * @author Michael Angstadt |
| 41 | */ |
| 42 | public class ImageProperty extends BinaryProperty<ImageType> { |
| 43 | /** |
| 44 | * Creates an image property. |
| 45 | * @param url the URL to the image |
| 46 | * @param type the content type (e.g. JPEG) |
| 47 | */ |
| 48 | public ImageProperty(String url, ImageType type) { |
| 49 | super(url, type); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Creates an image property. |
| 54 | * @param data the binary data of the image |
| 55 | * @param type the content type (e.g. JPEG) |
| 56 | */ |
| 57 | public ImageProperty(byte[] data, ImageType type) { |
| 58 | super(data, type); |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Creates an image property. |
| 63 | * @param in an input stream to the binary data (will be closed) |
| 64 | * @param type the content type (e.g. JPEG) |
| 65 | * @throws IOException if there's a problem reading from the input stream |
| 66 | */ |
| 67 | public ImageProperty(InputStream in, ImageType type) throws IOException { |
| 68 | super(in, type); |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Creates an image property. |
| 73 | * @param file the image file |
| 74 | * @param type the content type (e.g. JPEG) |
| 75 | * @throws IOException if there's a problem reading from the file |
| 76 | */ |
| 77 | public ImageProperty(Path file, ImageType type) throws IOException { |
| 78 | super(file, type); |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Copy constructor. |
| 83 | * @param original the property to make a copy of |
| 84 | */ |
| 85 | public ImageProperty(ImageProperty original) { |
| 86 | super(original); |
| 87 | } |
| 88 | } |