| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| AbstractAsfTagImageField |
|
| 1.0;1 |
| 1 | package org.jaudiotagger.tag.asf; | |
| 2 | ||
| 3 | import org.jaudiotagger.audio.asf.data.MetadataDescriptor; | |
| 4 | import org.jaudiotagger.tag.asf.AsfTagField; | |
| 5 | import org.jaudiotagger.tag.asf.AsfFieldKey; | |
| 6 | import org.jaudiotagger.tag.TagField; | |
| 7 | ||
| 8 | import javax.imageio.ImageIO; | |
| 9 | ||
| 10 | import java.awt.image.BufferedImage; | |
| 11 | import java.io.ByteArrayInputStream; | |
| 12 | import java.io.IOException; | |
| 13 | ||
| 14 | /** | |
| 15 | * An <code>AbstractAsfTagImageField</code> is an abstract class for representing tag | |
| 16 | * fields containing image data.<br> | |
| 17 | * | |
| 18 | * @author Christian Laireiter | |
| 19 | */ | |
| 20 | abstract class AbstractAsfTagImageField extends AsfTagField | |
| 21 | { | |
| 22 | ||
| 23 | /** | |
| 24 | * Creates a image tag field. | |
| 25 | * | |
| 26 | * @param field | |
| 27 | * the ASF field that should be represented. | |
| 28 | */ | |
| 29 | public AbstractAsfTagImageField(final AsfFieldKey field) { | |
| 30 | 0 | super(field); |
| 31 | 0 | } |
| 32 | ||
| 33 | /** | |
| 34 | * Creates an instance. | |
| 35 | * | |
| 36 | * @param source | |
| 37 | * The descriptor which should be represented as a | |
| 38 | * {@link TagField}. | |
| 39 | */ | |
| 40 | public AbstractAsfTagImageField(final MetadataDescriptor source) { | |
| 41 | 94 | super(source); |
| 42 | 94 | } |
| 43 | ||
| 44 | /** | |
| 45 | * Creates a tag field. | |
| 46 | * | |
| 47 | * @param fieldKey | |
| 48 | * The field identifier to use. | |
| 49 | */ | |
| 50 | public AbstractAsfTagImageField(final String fieldKey) { | |
| 51 | 0 | super(fieldKey); |
| 52 | 0 | } |
| 53 | ||
| 54 | /** | |
| 55 | * This method returns an image instance from the | |
| 56 | * {@linkplain #getRawImageData() image content}. | |
| 57 | * | |
| 58 | * @return the image instance | |
| 59 | * @throws IOException | |
| 60 | */ | |
| 61 | public BufferedImage getImage() throws IOException { | |
| 62 | 60 | return ImageIO.read(new ByteArrayInputStream(getRawImageData())); |
| 63 | } | |
| 64 | ||
| 65 | /** | |
| 66 | * Returns the size of the {@linkplain #getRawImageData() image data}.<br> | |
| 67 | * | |
| 68 | * @return image data size in bytes. | |
| 69 | */ | |
| 70 | public abstract int getImageDataSize(); | |
| 71 | ||
| 72 | /** | |
| 73 | * Returns the raw data of the represented image.<br> | |
| 74 | * | |
| 75 | * @return raw image data | |
| 76 | */ | |
| 77 | public abstract byte[] getRawImageData(); | |
| 78 | ||
| 79 | } |