< prev index next >
src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java
Print this page
@@ -515,22 +515,22 @@
* @param type One of the {@code TIFFTag.TIFF_*} constants
* indicating the data type of the field as written to the TIFF stream.
* @param count The number of data values.
* @param data The actual data content of the field.
*
- * @throws NullPointerException if {@code tag == null}.
+ * @throws NullPointerException if {@code tag == null}.
* @throws IllegalArgumentException if {@code type} is not
* 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}.
- * @throws IllegalArgumentException if {@code count < 1}
+ * @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}
+ * @throws IllegalArgumentException if {@code count != 1}
* and {@code type} is {@code TIFF_IFD_POINTER}.
- * @throws NullPointerException if {@code data == null}.
+ * @throws NullPointerException if {@code data == null}.
* @throws IllegalArgumentException if {@code data} is an instance of
* a class incompatible with the specified type.
* @throws IllegalArgumentException if the size of the data array is wrong.
*/
public TIFFField(TIFFTag tag, int type, int count, Object data) {
@@ -630,16 +630,16 @@
*
* @param tag The tag to associated with this field.
* @param type One of the {@code TIFFTag.TIFF_*} constants
* indicating the data type of the field as written to the TIFF stream.
* @param count The number of data values.
- * @throws NullPointerException if {@code tag == null}.
+ * @throws NullPointerException if {@code tag == null}.
* @throws IllegalArgumentException if {@code type} is not
* 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}.
+ * @throws IllegalArgumentException if {@code count < 0}.
* @see #TIFFField(TIFFTag,int,int,Object)
*/
public TIFFField(TIFFTag tag, int type, int count) {
this(tag, type, count, createArrayForType(type, count));
}
@@ -647,20 +647,20 @@
/**
* Constructs a {@code TIFFField} with a single non-negative integral
* value.
* The field will have type
* {@link TIFFTag#TIFF_SHORT TIFF_SHORT} if
- * {@code val < 65536} and type
+ * {@code val < 65536} and type
* {@link TIFFTag#TIFF_LONG TIFF_LONG} otherwise. The count
* of the field will be unity.
*
* @param tag The tag to associate with this field.
* @param value The value to associate with this field.
- * @throws NullPointerException if {@code tag == null}.
+ * @throws NullPointerException if {@code tag == null}.
* @throws IllegalArgumentException if the derived type is unacceptable
* for the supplied {@code TIFFTag}.
- * @throws IllegalArgumentException if {@code value < 0}.
+ * @throws IllegalArgumentException if {@code value < 0}.
*/
public TIFFField(TIFFTag tag, int value) {
if(tag == null) {
throw new NullPointerException("tag == null!");
}
@@ -703,31 +703,45 @@
* @param type One of the constants {@code TIFFTag.TIFF_LONG} or
* {@code TIFFTag.TIFF_IFD_POINTER}.
* @param offset The IFD offset.
* @param dir The directory.
*
- * @throws NullPointerException if {@code tag == null}.
- * @throws IllegalArgumentException if {@code type} is neither
- * {@code TIFFTag.TIFF_LONG} nor {@code TIFFTag.TIFF_IFD_POINTER}.
+ * @throws NullPointerException if {@code tag == null}.
* @throws IllegalArgumentException if {@code type} is an unacceptable
* data type for the supplied {@code TIFFTag}.
- * @throws IllegalArgumentException if {@code offset} is non-positive.
- * @throws NullPointerException if {@code dir == null}.
+ * @throws IllegalArgumentException if {@code type} is neither
+ * {@code TIFFTag.TIFF_LONG} nor {@code TIFFTag.TIFF_IFD_POINTER}.
+ * @throws IllegalArgumentException if {@code offset <= 0}.
+ * @throws NullPointerException if {@code dir == null}.
*
* @see #TIFFField(TIFFTag,int,int,Object)
*/
public TIFFField(TIFFTag tag, int type, long offset, TIFFDirectory dir) {
- this(tag, type, 1, new long[] {offset});
- if (type != TIFFTag.TIFF_LONG && type != TIFFTag.TIFF_IFD_POINTER) {
+ if(tag == null) {
+ throw new NullPointerException("tag == null!");
+ } else if(type < TIFFTag.MIN_DATATYPE || type > TIFFTag.MAX_DATATYPE) {
+ throw new IllegalArgumentException("Unknown data type "+type);
+ } else if(!tag.isDataTypeOK(type)) {
+ throw new IllegalArgumentException("Illegal data type " + type
+ + " for " + tag.getName() + " tag");
+ } else if (type != TIFFTag.TIFF_LONG
+ && type != TIFFTag.TIFF_IFD_POINTER) {
throw new IllegalArgumentException("type " + type
+ " is neither TIFFTag.TIFF_LONG nor TIFFTag.TIFF_IFD_POINTER");
} else if (offset <= 0) {
throw new IllegalArgumentException("offset " + offset
+ " is non-positive");
} else if (dir == null) {
throw new NullPointerException("dir == null");
}
+
+ this.tag = tag;
+ this.tagNumber = tag.getNumber();
+ this.type = type;
+ this.count = 1;
+ this.data = new long[] {offset};
+
this.dir = dir;
}
/**
* Retrieves the tag associated with this field.
@@ -737,11 +751,11 @@
public TIFFTag getTag() {
return tag;
}
/**
- * Retrieves the tag number in the range {@code [0, 65535]}.
+ * Retrieves the tag number in the range {@code [0,65535]}.
*
* @return The tag number.
*/
public int getTagNumber() {
return tagNumber;
@@ -802,11 +816,11 @@
* @param count The number of values in the array.
* @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 < 0}.
*/
public static Object createArrayForType(int dataType, int count) {
if(count < 0) {
throw new IllegalArgumentException("count < 0!");
}
< prev index next >