| Class | Line # | Actions | |||||
|---|---|---|---|---|---|---|---|
| ImageData | 32 | 5 | 0% | 4 | 6 |
| 1 | /* | |
| 2 | * See the NOTICE file distributed with this work for additional | |
| 3 | * information regarding copyright ownership. | |
| 4 | * | |
| 5 | * This is free software; you can redistribute it and/or modify it | |
| 6 | * under the terms of the GNU Lesser General Public License as | |
| 7 | * published by the Free Software Foundation; either version 2.1 of | |
| 8 | * the License, or (at your option) any later version. | |
| 9 | * | |
| 10 | * This software is distributed in the hope that it will be useful, | |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | * Lesser General Public License for more details. | |
| 14 | * | |
| 15 | * You should have received a copy of the GNU Lesser General Public | |
| 16 | * License along with this software; if not, write to the Free | |
| 17 | * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | |
| 18 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org. | |
| 19 | */ | |
| 20 | package org.xwiki.formula; | |
| 21 | ||
| 22 | import java.io.Serializable; | |
| 23 | ||
| 24 | import org.xwiki.formula.FormulaRenderer.Type; | |
| 25 | ||
| 26 | /** | |
| 27 | * Rendered image. | |
| 28 | * | |
| 29 | * @version $Id: 175abf19b8e88310478469dccf940d60e9627793 $ | |
| 30 | * @since 2.0M3 | |
| 31 | */ | |
| 32 | public class ImageData implements Serializable | |
| 33 | { | |
| 34 | /** Unique version number used for serialization. */ | |
| 35 | private static final long serialVersionUID = 200908111440L; | |
| 36 | ||
| 37 | /** Binary image data. */ | |
| 38 | protected final byte[] data; | |
| 39 | ||
| 40 | /** Image format. */ | |
| 41 | protected final Type type; | |
| 42 | ||
| 43 | /** | |
| 44 | * Simple constructor which initializes the binary image data and the image format. | |
| 45 | * | |
| 46 | * @param data the binary image data. See {@link #data}. | |
| 47 | * @param type the image format. See {@link #type}. | |
| 48 | */ | |
| 49 | 2 | public ImageData(byte[] data, Type type) |
| 50 | { | |
| 51 | 2 | this.data = data; |
| 52 | 2 | this.type = type; |
| 53 | } | |
| 54 | ||
| 55 | /** | |
| 56 | * Access to the image data. | |
| 57 | * | |
| 58 | * @return the binary image data | |
| 59 | * @see #data | |
| 60 | */ | |
| 61 | 0 | public byte[] getData() |
| 62 | { | |
| 63 | 0 | return this.data; |
| 64 | } | |
| 65 | ||
| 66 | /** | |
| 67 | * Access to the image format. | |
| 68 | * | |
| 69 | * @return the image format | |
| 70 | * @see #type | |
| 71 | */ | |
| 72 | 0 | public Type getType() |
| 73 | { | |
| 74 | 0 | return this.type; |
| 75 | } | |
| 76 | ||
| 77 | /** | |
| 78 | * Quick access to the image MIME type. | |
| 79 | * | |
| 80 | * @return the MIME type corresponding to the stored image, in the format defined in RFC 2045 | |
| 81 | * @see #type | |
| 82 | */ | |
| 83 | 0 | public String getMimeType() |
| 84 | { | |
| 85 | 0 | return this.type.getMimetype(); |
| 86 | } | |
| 87 | } |