< prev index next >

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

Print this page




 641      * parameters and the created array.
 642      *
 643      * @param tag The tag to associated with this field.
 644      * @param type One of the {@code TIFFTag.TIFF_*} constants
 645      * indicating the data type of the field as written to the TIFF stream.
 646      * @param count The number of data values.
 647      * @throws NullPointerException if {@code tag == null}.
 648      * @throws IllegalArgumentException if {@code type} is not
 649      * one of the {@code TIFFTag.TIFF_*} data type constants.
 650      * @throws IllegalArgumentException if {@code type} is an unacceptable
 651      * data type for the supplied {@code TIFFTag}.
 652      * @throws IllegalArgumentException if {@code count < 0}.
 653      * @see #TIFFField(TIFFTag,int,int,Object)
 654      */
 655     public TIFFField(TIFFTag tag, int type, int count) {
 656         this(tag, type, count, createArrayForType(type, count));
 657     }
 658 
 659     /**
 660      * Constructs a {@code TIFFField} with a single non-negative integral
 661      * value.
 662      * The field will have type
 663      * {@link TIFFTag#TIFF_SHORT  TIFF_SHORT} if
 664      * {@code val < 65536} and type
 665      * {@link TIFFTag#TIFF_LONG TIFF_LONG} otherwise.  The count
 666      * of the field will be unity.
 667      *
 668      * @param tag The tag to associate with this field.
 669      * @param value The value to associate with this field.
 670      * @throws NullPointerException if {@code tag == null}.
 671      * @throws IllegalArgumentException if the derived type is unacceptable
 672      * for the supplied {@code TIFFTag}.
 673      * @throws IllegalArgumentException if {@code value < 0}.



 674      */
 675     public TIFFField(TIFFTag tag, int value) {
 676         if(tag == null) {
 677             throw new NullPointerException("tag == null!");
 678         }
 679         if (value < 0) {
 680             throw new IllegalArgumentException("value < 0!");
 681         }



 682 
 683         this.tag = tag;
 684         this.tagNumber = tag.getNumber();
 685         this.count = 1;
 686 
 687         if (value < 65536) {
 688             if (!tag.isDataTypeOK(TIFFTag.TIFF_SHORT)) {
 689                 throw new IllegalArgumentException("Illegal data type "
 690                     + TIFFTag.TIFF_SHORT + " for " + tag.getName() + " tag");
 691             }
 692             this.type = TIFFTag.TIFF_SHORT;
 693             char[] cdata = new char[1];
 694             cdata[0] = (char)value;
 695             this.data = cdata;
 696         } else {
 697             if (!tag.isDataTypeOK(TIFFTag.TIFF_LONG)) {
 698                 throw new IllegalArgumentException("Illegal data type "
 699                     + TIFFTag.TIFF_LONG + " for " + tag.getName() + " tag");
 700             }
 701             this.type = TIFFTag.TIFF_LONG;




 641      * parameters and the created array.
 642      *
 643      * @param tag The tag to associated with this field.
 644      * @param type One of the {@code TIFFTag.TIFF_*} constants
 645      * indicating the data type of the field as written to the TIFF stream.
 646      * @param count The number of data values.
 647      * @throws NullPointerException if {@code tag == null}.
 648      * @throws IllegalArgumentException if {@code type} is not
 649      * one of the {@code TIFFTag.TIFF_*} data type constants.
 650      * @throws IllegalArgumentException if {@code type} is an unacceptable
 651      * data type for the supplied {@code TIFFTag}.
 652      * @throws IllegalArgumentException if {@code count < 0}.
 653      * @see #TIFFField(TIFFTag,int,int,Object)
 654      */
 655     public TIFFField(TIFFTag tag, int type, int count) {
 656         this(tag, type, count, createArrayForType(type, count));
 657     }
 658 
 659     /**
 660      * Constructs a {@code TIFFField} with a single non-negative integral
 661      * value. The field will have type {@link TIFFTag#TIFF_SHORT TIFF_SHORT}
 662      * if {@code value} is in {@code [0,65535]}, and type
 663      * {@link TIFFTag#TIFF_LONG TIFF_LONG} if {@code value} is in
 664      * {@code [65536,4294967295]}. The count of the field will be unity.


 665      *
 666      * @param tag The tag to associate with this field.
 667      * @param value The value to associate with this field.
 668      * @throws NullPointerException if {@code tag == null}.
 669      * @throws IllegalArgumentException if {@code value} is not in
 670      * {@code [0,4294967295]}.
 671      * @throws IllegalArgumentException if {@code value} is in {@code [0,65535]}
 672      * and {@code TIFF_SHORT} is an unacceptable type for the {@code TIFFTag},
 673      * or if {@code value} is in {@code [65536,4294967295]} and
 674      * {@code TIFF_LONG} is an unacceptable type for the {@code TIFFTag}.
 675      */
 676     public TIFFField(TIFFTag tag, long value) {
 677         if(tag == null) {
 678             throw new NullPointerException("tag == null!");
 679         }
 680         if (value < 0) {
 681             throw new IllegalArgumentException("value < 0!");
 682         }
 683         if (value > 0xffffffffL) {
 684             throw new IllegalArgumentException("value > 4294967295!");
 685         }
 686 
 687         this.tag = tag;
 688         this.tagNumber = tag.getNumber();
 689         this.count = 1;
 690 
 691         if (value < 65536) {
 692             if (!tag.isDataTypeOK(TIFFTag.TIFF_SHORT)) {
 693                 throw new IllegalArgumentException("Illegal data type "
 694                     + TIFFTag.TIFF_SHORT + " for " + tag.getName() + " tag");
 695             }
 696             this.type = TIFFTag.TIFF_SHORT;
 697             char[] cdata = new char[1];
 698             cdata[0] = (char)value;
 699             this.data = cdata;
 700         } else {
 701             if (!tag.isDataTypeOK(TIFFTag.TIFF_LONG)) {
 702                 throw new IllegalArgumentException("Illegal data type "
 703                     + TIFFTag.TIFF_LONG + " for " + tag.getName() + " tag");
 704             }
 705             this.type = TIFFTag.TIFF_LONG;


< prev index next >