2 * Sone - TemporaryImage.java - Copyright © 2011–2013 David Roden
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package net.pterodactylus.sone.data;
20 import static com.google.common.base.Preconditions.checkNotNull;
22 import java.util.UUID;
25 * A temporary image stores an uploaded image in memory until it has been
26 * inserted into Freenet and is subsequently loaded from there.
28 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
30 public class TemporaryImage {
32 /** The ID of the temporary image. */
33 private final String id;
35 /** The MIME type of the image. */
36 private final String mimeType;
38 /** The encoded image data. */
39 private final byte[] imageData;
41 private final int width;
43 private final int height;
46 * Creates a new temporary image with a random ID.
50 public TemporaryImage(String mimeType, byte[] imageData, int width, int height) {
51 this.id = UUID.randomUUID().toString();
52 this.mimeType = checkNotNull(mimeType, "mime type must not be null");
53 this.imageData = checkNotNull(imageData, "image data must not be null");
59 * Returns the ID of the temporary image.
61 * @return The ID of the temporary image
63 public String getId() {
68 * Returns the MIME type of the image.
70 * @return The MIME type of the image
72 public String getMimeType() {
77 * Returns the encoded image data.
79 * @return The encoded image data
81 public byte[] getImageData() {
85 public int getWidth() {
89 public int getHeight() {