< prev index next >

src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java

Print this page

        

*** 696,705 **** --- 696,710 ---- * one of the {@code TIFFTag.TIFF_*} data type constants. * @throws IllegalArgumentException if {@code type} is an unacceptable * data type for the supplied {@code TIFFTag}. * @throws IllegalArgumentException if {@code count < 0}. * @see #TIFFField(TIFFTag,int,int,Object) + * @throws IllegalArgumentException if {@code count < 1} + * and {@code type} is {@code TIFF_RATIONAL} or + * {@code TIFF_SRATIONAL}. + * @throws IllegalArgumentException if {@code count != 1} + * and {@code type} is {@code TIFF_IFD_POINTER}. */ public TIFFField(TIFFTag tag, int type, int count) { this(tag, type, count, createArrayForType(type, count)); }
*** 883,897 **** --- 888,917 ---- * @return An array appropriate for the specified data type. * * @throws IllegalArgumentException if {@code dataType} is not * one of the {@code TIFFTag.TIFF_*} data type constants. * @throws IllegalArgumentException if {@code count < 0}. + * @throws IllegalArgumentException if {@code count < 1} + * and {@code type} is {@code TIFF_RATIONAL} or + * {@code TIFF_SRATIONAL}. + * @throws IllegalArgumentException if {@code count != 1} + * and {@code type} is {@code TIFF_IFD_POINTER}. */ public static Object createArrayForType(int dataType, int count) { + if(count < 0) { throw new IllegalArgumentException("count < 0!"); + } else if((dataType == TIFFTag.TIFF_RATIONAL + || dataType == TIFFTag.TIFF_SRATIONAL) + && count < 1) { + throw new IllegalArgumentException + ("Type is TIFF_RATIONAL or TIFF_SRATIONAL and count < 1"); + } else if (dataType == TIFFTag.TIFF_IFD_POINTER && count != 1) { + throw new IllegalArgumentException + ("Type is TIFF_IFD_POINTER count != 1"); } + switch (dataType) { case TIFFTag.TIFF_BYTE: case TIFFTag.TIFF_SBYTE: case TIFFTag.TIFF_UNDEFINED: return new byte[count];
< prev index next >